diff options
author | Lluis Sanchez <lluis@novell.com> | 2007-12-04 13:57:22 +0300 |
---|---|---|
committer | Lluis Sanchez <lluis@novell.com> | 2007-12-04 13:57:22 +0300 |
commit | d60f689f45a88295971c324518d0e05b774016ae (patch) | |
tree | 279d50e9aa1659b27b5e6efe974ae678460be4cc /extras | |
parent | 3693ff8d3f9ad1ab442a0bf8042017129bede938 (diff) |
Directory reorganization
svn path=/branches/monodevelop/reorg/; revision=90647
Diffstat (limited to 'extras')
371 files changed, 40147 insertions, 0 deletions
diff --git a/extras/MonoDevelop.Database/Makefile.am b/extras/MonoDevelop.Database/Makefile.am new file mode 100644 index 0000000000..b5a4b0eccd --- /dev/null +++ b/extras/MonoDevelop.Database/Makefile.am @@ -0,0 +1,3 @@ +if ENABLE_DATABASE +SUBDIRS = MonoDevelop.Database.Sql MonoDevelop.Database.Components MonoDevelop.Database.Query MonoDevelop.Database.Designer MonoDevelop.Database.ConnectionManager MonoDevelop.Database.Sql.MySql MonoDevelop.Database.Sql.SqlServer MonoDevelop.Database.Sql.Sqlite MonoDevelop.Database.Sql.Npgsql +endif diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/AssemblyInfo.cs.in b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/AssemblyInfo.cs.in new file mode 100644 index 0000000000..cf467e3234 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/AssemblyInfo.cs.in @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("MonoDevelop.Database.Components")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("http://www.monodevelop.com")] +[assembly: AssemblyCopyright("MIT X11 - Ben Motmans")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: AssemblyVersion("@ASSEMBLY_VERSION@")] + +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/ChangeLog b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/ChangeLog new file mode 100644 index 0000000000..6200e3e8b3 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/ChangeLog @@ -0,0 +1,144 @@ +2007-11-09 Michael Hutchinson <mhutchinson@novell.com> + + * Widgets/DataGrid/DataGrid.cs: Track LoggingService API. Replace some + "LogError" calls with "LogDebug" calls. + +2007-10-29 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Components.addin.xml: Bump MD version. + +2007-10-23 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Components.mdp: Project file names updated by change + in MD path functions. + +2007-10-16 Lluis Sanchez Gual <lluis@novell.com> + + * gtk-gui/gui.stetic, MonoDevelop.Database.Components.mdp: Fix required GTK# + version. + +2007-10-02 Ben Motmans <ben.motmans@gmail.com> + + * Dialogs/DatabaseConnectionSettingsDialog.cs: Allow empty passwords + +2007-09-26 Michael Hutchinson <mhutchinson@novell.com> + + * Makefile.am: Don't deploy .addin.xml file. + * MonoDevelop.Database.Components.mdp: Don't unnecessarily local-copy + project references. Don't sync EXTRA_DIST with deploy files. Add + Makefile.am to file list. + +2007-09-21 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Components.addin.xml: Bump MD version. + +2007-09-19 Ben Motmans <ben.motmans@gmail.com> + + + +2007-09-16 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: link to the correct Mono.Addins dll + +2007-09-07 Ben Motmans <ben.motmans@gmail.com> + + * Dialogs/DatabaseConnectionSettingsDialog.cs: improved capabilities system + +2007-08-29 Ben Motmans <ben.motmans@gmail.com> + + * MonoDevelop.Database.Components.addin.xml: use updated ExtensionNodeSet + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * Widgets/DataGrid/DataGrid.cs: added a missing " char + * gtk-gui/gui.stetic, Makefile.am, MonoDevelop.Database.Components.mdp: use + project references instead of assembly references + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * Widgets/DataGrid/DataGrid.cs, Widgets/SqlEditorWidget.cs, + MonoDevelop.Database.Components.addin.xml: updated addin paths + * Makefile.am: updated makefile + +2007-08-03 Ben Motmans <ben.motmans@gmail.com> + + * Widgets/SqlEditorWidget.cs: fixed the context menu + +2007-08-02 Ben Motmans <ben.motmans@gmail.com> + + * Dialogs/DatabaseConnectionSettingsDialog.cs: make sure the database entry is always editable + * Widgets/SelectColumnWidget.cs, Widgets/SortedColumnListStore.cs: moved the liststore into a + separate SortedColumnListStore class that can easily be reused + * Widgets/DataGrid/DataGrid.cs: improved gchar workaround + + * Widgets/SelectColumnWidget.cs: added SingleMode property to force single selects + +2007-08-01 Ben Motmans <ben.motmans@gmail.com> + + * Widgets/DataGrid/DataGrid.cs: Added workaround for chars in the liststore + * Widgets/SqlEditorWidget.cs: Added a scrolledwindow + * Widgets/SelectColumnWidget.cs: IsColumnChecked property to verify that at least + 1 column is selected + * Dialogs/SelectColumnDialog.cs: SelectAll and DeselectAll buttons + * Dialogs/WaitDialog.cs: Correctly draw the window border + +2007-07-31 Ben Motmans <ben.motmans@gmail.com> + + * Widgets/SelectColumnWidget.cs: various bugfixes + * Widgets/SqlEditorWidget.cs: Added a addin based context menu and added + ExportToFile and ImportFromFile commands + +2007-07-25 Ben Motmans <ben.motmans@gmail.com> + + * Dialogs/DatabaseConnectionSettingsDialog.cs: Various improvements and bugfixes + * Commands/SqlEditorCommands.cs, Commands/DataGridCommands.cs: Commands + * Dialogs/WaitDialog.cs: Dialog to alert the user of progress during a + background operation + * Widgets/DataGrid/Visualizers/DataGridItemCommandHandler.cs: Command + Handler for DataGrid context menu's + * Widgets/DataGrid/Visualizers/AbstractDataGridVisualizer.cs: Abstract + Visualizer implementation + * Widgets/DatabaseConnectionContextComboBox.cs: ComboBox to list all + DatabaseConnectionContexts + * Widgets/SqlEditorWidget.cs: re-useable sql editor with syntax highlighting + * MonoDevelop.Database.Components.addin.xml: addin definitions + +2007-07-18 Ben Motmans <ben.motmans@gmail.com> + + * Dialogs/DatabaseConnectionSettingsDialog.cs: Do not make the name entry and provider combo + insensitive when the custom connection string checkbutton is activated + +2007-07-17 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: initial makefile + * Widgets/ConnectionComboBox.cs, Dialogs/ShowXmlTreeDialog.cs, Dialogs/PasswordDialog.cs: + removed obsolete classes + * Dialogs/DatabaseConnectionSettingsDialog.cs: improved connection settings dialog, fixes most of the old bugs + +2007-07-14 Ben Motmans <ben.motmans@gmail.com> + + * Widgets/DataGrid/*: New DataGrid widget, with support for data visualizers and content based renderers + * Dialogs/ShowTextDialog.cs: Text visualization widget for the DataGrid control + * Dialogs/ShowImageDialog.cs: Image visualization widget for the DataGrid control + * Dialogs/ShowXmlTreeDialog.cs: XML visualization widget for the DataGrid control + * Codons/DataGridContentRendererCodon.cs: Codon to add content renderers to the datagrid control + * Codons/DataGridVisualizerCodon.cs: Codon to add visualizers to the datagrid control + +2007-07-10 Ben Motmans <ben.motmans@gmail.com> + + * Dialogs/ConnectionDialog.cs: imported from ConnectionManager project, added CheckBox + to set the ConnectionSettings SavePassword property, various other bugfixes + * Dialogs/PasswordDialog.cs: password dialog + * Widgets/DataGrid/*: imported from Query project + * Widgets/ConnectionComboBox.cs: ComboBox that lists all ConnectionSettings + +2007-07-09 Ben Motmans <ben.motmans@gmail.com> + + * Project: re-usable gtk# data controls + * Containers/*.cs: Data objects for use inside custom widgets + * Dialogs/SelectColumnDialog.cs: Dialog to select columns + * Widgets/CellRendererTypeCombo.cs: CellRendererCombo with a list of all standard .NET data types + * Widgets/ColumnMappingWidget.cs: ListView used to map ColumnSchema objects to .NET objects + * Widgets/ProjectDirectoryComboBox.cs: Combo used to select a target project or directory + * Widgets/SelectColumnWidget.cs: ListView to select ColumnSchema objects + * Widgets/SelectSchemaWidget.cs: ListView to select Table, View or Procedure schemas diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Codons/DataGridContentRendererCodon.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Codons/DataGridContentRendererCodon.cs new file mode 100644 index 0000000000..57588f0105 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Codons/DataGridContentRendererCodon.cs @@ -0,0 +1,39 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; +using Mono.Addins; + +namespace MonoDevelop.Database.Components +{ + public class DataGridContentRendererCodon : TypeExtensionNode + { + public IDataGridContentRenderer ContentRenderer { + get { return (IDataGridContentRenderer)base.CreateInstance (); } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Commands/DataGridCommands.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Commands/DataGridCommands.cs new file mode 100644 index 0000000000..6a63190366 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Commands/DataGridCommands.cs @@ -0,0 +1,45 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Gtk; +using System; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.Components +{ + public enum DataGridCommands + { + VisualizeAsText, + VisualizeAsXmlText, + VisualizeAsXmlTree, + VisualizeAsImage + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Commands/SqlEditorCommands.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Commands/SqlEditorCommands.cs new file mode 100644 index 0000000000..7abfd16466 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Commands/SqlEditorCommands.cs @@ -0,0 +1,43 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Gtk; +using System; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.Components +{ + public enum SqlEditorCommands + { + ImportFromFile, + ExportToFile + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Containers/ColumnContainer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Containers/ColumnContainer.cs new file mode 100644 index 0000000000..2724dc8806 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Containers/ColumnContainer.cs @@ -0,0 +1,79 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections.Generic;using MonoDevelop.Database.Sql; + +namespace MonoDevelop.Database.Components +{ + public class ColumnContainer + { + private ColumnSchema column; + private string propName; + private string propType; + private bool hasSetter; + private bool isCtorParam; + + public ColumnContainer (ColumnSchema column) + { + if (column == null) + throw new ArgumentNullException ("column"); + this.column = column; + } + + public ColumnSchema ColumnSchema { + get { return column; } + } + + public string PropertyName { + get { return propName; } + set { + if (String.IsNullOrEmpty (value)) + throw new ArgumentException ("PropertyName"); + propName = value; + } + } + + public string PropertyType { + get { return propType; } + set { + if (String.IsNullOrEmpty (value)) + throw new ArgumentException ("PropertyType"); + propType = value; + } + } + + public bool HasSetter { + get { return hasSetter; } + set { hasSetter = value; } + } + + public bool IsCtorParameter { + get { return isCtorParam; } + set { isCtorParam = value; } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Containers/ConditionContainer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Containers/ConditionContainer.cs new file mode 100644 index 0000000000..7950401615 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Containers/ConditionContainer.cs @@ -0,0 +1,3 @@ + +// created on 7/8/2007 at 11:13 PM +//TODO:
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Containers/ParameterContainer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Containers/ParameterContainer.cs new file mode 100644 index 0000000000..ef22ab3ebf --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Containers/ParameterContainer.cs @@ -0,0 +1,67 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections.Generic;using MonoDevelop.Database.Sql; + +namespace MonoDevelop.Database.Components +{ + public class ParameterContainer + { + private ParameterSchema parameter; + private string propName; + private string propType; + + public ParameterContainer (ParameterSchema parameter) + { + if (parameter == null) + throw new ArgumentNullException ("parameter"); + this.parameter = parameter; + } + + public ParameterSchema ParameterSchema { + get { return parameter; } + } + + public string PropertyName { + get { return propName; } + set { + if (String.IsNullOrEmpty (value)) + throw new ArgumentException ("PropertyName"); + propName = value; + } + } + + public string PropertyType { + get { return propType; } + set { + if (String.IsNullOrEmpty (value)) + throw new ArgumentException ("PropertyType"); + propType = value; + } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Containers/SchemaContainers.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Containers/SchemaContainers.cs new file mode 100644 index 0000000000..d0883c2357 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Containers/SchemaContainers.cs @@ -0,0 +1,137 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections.Generic;using MonoDevelop.Database.Sql; + +namespace MonoDevelop.Database.Components +{ + public interface ISchemaContainer + { + ISchema Schema { get; } + + ColumnSchemaCollection Columns { get; } + + ParameterSchemaCollection Parameters { get; } + + SchemaContainerType SchemaContainerType { get; } + } + + public enum SchemaContainerType + { + Table, + View, + Procedure, + Query + } + + public class TableSchemaContainer : ISchemaContainer + { + protected TableSchema schema; + + public TableSchemaContainer (TableSchema schema) + { + if (schema == null) + throw new ArgumentNullException ("schema"); + + this.schema = schema; + } + + public ISchema Schema { + get { return schema; } + } + + public ColumnSchemaCollection Columns { + get { return schema.Columns; } + } + + public ParameterSchemaCollection Parameters { + get { return null; } + } + + public SchemaContainerType SchemaContainerType { + get { return SchemaContainerType.Table; } + } + } + + public class ViewSchemaContainer : ISchemaContainer + { + protected ViewSchema schema; + + public ViewSchemaContainer (ViewSchema schema) + { + if (schema == null) + throw new ArgumentNullException ("schema"); + + this.schema = schema; + } + + public ISchema Schema { + get { return schema; } + } + + public ColumnSchemaCollection Columns { + get { return schema.Columns; } + } + + public ParameterSchemaCollection Parameters { + get { return null; } + } + + public SchemaContainerType SchemaContainerType { + get { return SchemaContainerType.View; } + } + } + + public class ProcedureSchemaContainer : ISchemaContainer + { + protected ProcedureSchema schema; + + public ProcedureSchemaContainer (ProcedureSchema schema) + { + if (schema == null) + throw new ArgumentNullException ("schema"); + + this.schema = schema; + } + + public ISchema Schema { + get { return schema; } + } + + public ParameterSchemaCollection Parameters { + get { return schema.Parameters; } + } + + public SchemaContainerType SchemaContainerType { + get { return SchemaContainerType.Procedure; } + } + + public ColumnSchemaCollection Columns { + get { throw new NotImplementedException (); } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Dialogs/DatabaseConnectionSettingsDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Dialogs/DatabaseConnectionSettingsDialog.cs new file mode 100644 index 0000000000..c316fda103 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Dialogs/DatabaseConnectionSettingsDialog.cs @@ -0,0 +1,411 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Threading; +using System.Collections.Generic; +using Mono.Addins; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Database.Sql; + +namespace MonoDevelop.Database.Components +{ + public partial class DatabaseConnectionSettingsDialog : Gtk.Dialog + { + protected bool isEditMode; + protected bool isCreateDbMode; + protected DatabaseConnectionSettings settings; + + protected bool isDefaultSettings; + + protected ListStore storeProviders; + protected ListStore storeDatabases; + protected bool isDatabaseListEmpty; + + protected bool enableServerEntry; + protected bool enablePortEntry; + protected bool enableUsernameEntry; + protected bool enablePasswordEntry; + protected bool enableOpenButton; + protected bool enableRefreshButton; + + //TODO: add warning when no providers are available (not in isCreateDbMode) + protected DatabaseConnectionSettingsDialog (bool isEditMode, bool isCreateDbMode) + { + this.Build (); + + this.isEditMode = isEditMode; + this.isCreateDbMode = isCreateDbMode; + + if (isEditMode) + Title = GettextCatalog.GetString ("Edit Database Connection"); + else + Title = GettextCatalog.GetString ("Add Database Connection"); + + textConnectionString.Buffer.Changed += new EventHandler (ConnectionStringChanged); + checkCustom.Toggled += new EventHandler (CustomConnectionStringActivated); + + storeProviders = new ListStore (typeof (string), typeof (object)); + comboProvider.Model = storeProviders; + + storeDatabases = comboDatabase.Model as ListStore; + comboDatabase.TextColumn = 0; + comboDatabase.Entry.Changed += new EventHandler (DatabaseChanged); + + CellRendererText providerRenderer = new CellRendererText (); + comboProvider.PackStart (providerRenderer, true); + comboProvider.AddAttribute (providerRenderer, "text", 0); + + if (isCreateDbMode) { + comboDatabase.Sensitive = false; + buttonOpen.Sensitive = false; + buttonRefresh.Sensitive = false; + checkCustom.Sensitive = false; + } + + foreach (IDbFactory fac in DbFactoryService.DbFactories) + storeProviders.AppendValues (fac.Name, fac); + TreeIter iter; + if (storeProviders.GetIterFirst (out iter)) + comboProvider.SetActiveIter (iter); + } + + public DatabaseConnectionSettingsDialog () + : this (false) + { + } + + public DatabaseConnectionSettingsDialog (DatabaseConnectionSettings settings) + : this (true, false) + { + if (settings == null) + throw new ArgumentNullException ("settings"); + + this.settings = settings; + ShowSettings (settings, true); + + storeDatabases.AppendValues (settings.Database); + isDatabaseListEmpty = false; + } + + public DatabaseConnectionSettingsDialog (bool isCreateDbMode) + : this (false, isCreateDbMode) + { + settings = new DatabaseConnectionSettings (); + isDefaultSettings = true; + + if (!isCreateDbMode) { + storeDatabases.AppendValues (GettextCatalog.GetString ("No databases found!")); + isDatabaseListEmpty = true; + } + } + + public DatabaseConnectionSettings ConnectionSettings { + get { return settings; } + } + + public bool EnableServerEntry { + get { return enableServerEntry; } + set { enableServerEntry = value; } + } + + public bool EnablePortEntry { + get { return enablePortEntry; } + set { enablePortEntry = value; } + } + + public bool EnableUsernameEntry { + get { return enableUsernameEntry; } + set { enableUsernameEntry = value; } + } + + public bool EnablePasswordEntry { + get { return enablePasswordEntry; } + set { enablePasswordEntry = value; } + } + + public bool EnableOpenButton { + get { return enableOpenButton; } + set { enableOpenButton = value; } + } + + public bool EnableRefreshButton { + get { return enableRefreshButton; } + set { enableRefreshButton = value; } + } + + protected virtual void NameChanged (object sender, System.EventArgs e) + { + CheckSettings (); + } + + protected virtual void ServerChanged (object sender, System.EventArgs e) + { + CheckSettings (); + } + + protected virtual void PortChanged (object sender, System.EventArgs e) + { + CheckSettings (); + } + + protected virtual void UsernameChanged (object sender, System.EventArgs e) + { + CheckSettings (); + } + + protected virtual void OnOkClicked (object sender, System.EventArgs e) + { + FillDatabaseConnectionSettings (settings); + + Respond (ResponseType.Ok); + Hide (); + } + + protected virtual void OnCancelClicked (object sender, System.EventArgs e) + { + Respond (ResponseType.Cancel); + Hide (); + } + + protected virtual void PasswordChanged (object sender, System.EventArgs e) + { + CheckSettings (); + } + + protected virtual void RefreshClicked (object sender, System.EventArgs e) + { + DatabaseConnectionSettings settingsCopy = CreateDatabaseConnectionSettings (); + storeDatabases.Clear (); + + ThreadPool.QueueUserWorkItem (new WaitCallback (RefreshClickedThreaded), settingsCopy); + } + + protected virtual void RefreshClickedThreaded (object state) + { + DatabaseConnectionSettings settings = state as DatabaseConnectionSettings; + DatabaseConnectionContext context = new DatabaseConnectionContext (settings); + IDbFactory fac = DbFactoryService.GetDbFactory (settings.ProviderIdentifier); + try { + FakeConnectionPool pool = new FakeConnectionPool (fac, fac.ConnectionProvider, context); + pool.Initialize (); + + ISchemaProvider prov = fac.CreateSchemaProvider (pool); + DatabaseSchemaCollection databases = prov.GetDatabases (); + + foreach (DatabaseSchema db in databases) { + DispatchService.GuiDispatch (delegate () { + storeDatabases.AppendValues (db.Name); + }); + } + isDatabaseListEmpty = databases.Count == 0; + } catch {} + + if (isDatabaseListEmpty) { + DispatchService.GuiDispatch (delegate () { + storeDatabases.AppendValues (GettextCatalog.GetString ("No databases found!")); + }); + } else { + DispatchService.GuiDispatch (delegate () { + TreeIter iter; + if (storeDatabases.GetIterFirst (out iter)) + comboDatabase.SetActiveIter (iter); + }); + } + } + + protected virtual void OpenClicked (object sender, System.EventArgs e) + { + DatabaseConnectionSettings settingsCopy = CreateDatabaseConnectionSettings (); + IDbFactory fac = DbFactoryService.GetDbFactory (settingsCopy.ProviderIdentifier); + + string database = null; + if (fac.GuiProvider.ShowSelectDatabaseDialog (false, out database)) { + if (isDatabaseListEmpty) + storeDatabases.Clear (); //clear the fake node + isDatabaseListEmpty = false; + + TreeIter iter = storeDatabases.AppendValues (database); + comboDatabase.SetActiveIter (iter); + } + } + + protected virtual void MinPoolSizeChanged (object sender, System.EventArgs e) + { + if (spinMinPoolSize.Value > spinMaxPoolSize.Value) + spinMaxPoolSize.Value = spinMinPoolSize.Value; + } + + protected virtual void MaxPoolSizeChanged (object sender, System.EventArgs e) + { + if (spinMaxPoolSize.Value < spinMinPoolSize.Value) + spinMinPoolSize.Value = spinMaxPoolSize.Value; + } + + protected virtual void CustomConnectionStringActivated (object sender, System.EventArgs e) + { + bool sens = !checkCustom.Active; + + entryPassword.Sensitive = sens && enablePasswordEntry; + entryUsername.Sensitive = sens && enableUsernameEntry; + entryServer.Sensitive = sens && enableServerEntry; + spinPort.Sensitive = sens && enablePortEntry; + comboDatabase.Sensitive = sens && !isCreateDbMode; + buttonOpen.Sensitive = sens && enableOpenButton && !isCreateDbMode; + buttonRefresh.Sensitive = sens && enableRefreshButton && !isCreateDbMode; + scrolledwindow.Sensitive = !sens; + } + + protected virtual void ConnectionStringChanged (object sender, EventArgs e) + { + CheckSettings (); + } + + protected virtual void DatabaseChanged (object sender, EventArgs e) + { + if (isDatabaseListEmpty && comboDatabase.Entry.Text == GettextCatalog.GetString ("No databases found!")) { + comboDatabase.Entry.Text = String.Empty; + } + + CheckSettings (); + } + + protected virtual void CheckSettings () + { + isDefaultSettings = false; + buttonOk.Sensitive = ValidateFields (); + } + + protected virtual bool ValidateFields () + { + bool ok = false; + if (checkCustom.Active) { + ok = textConnectionString.Buffer.Text.Length > 0; + } else { + TreeIter iter; + ok = entryName.Text.Length > 0 + && (entryServer.Text.Length > 0 || !enableServerEntry) + && (entryUsername.Text.Length > 0 || !enableUsernameEntry) + && (comboDatabase.Entry.Text.Length > 0 || isCreateDbMode) + && comboProvider.GetActiveIter (out iter); + } + return ok; + } + + protected virtual DatabaseConnectionSettings CreateDatabaseConnectionSettings () + { + DatabaseConnectionSettings settings = new DatabaseConnectionSettings (); + FillDatabaseConnectionSettings (settings); + return settings; + } + + protected virtual void FillDatabaseConnectionSettings (DatabaseConnectionSettings settings) + { + settings.ConnectionString = textConnectionString.Buffer.Text; + settings.UseConnectionString = checkCustom.Active; + settings.MinPoolSize = (int)spinMinPoolSize.Value; + settings.MaxPoolSize = (int)spinMaxPoolSize.Value; + settings.Name = entryName.Text; + settings.Username = entryUsername.Text; + settings.Password = entryPassword.Text; + settings.Server = entryServer.Text; + settings.Port = (int)spinPort.Value; + settings.Database = comboDatabase.Entry.Text; + settings.SavePassword = checkSavePassword.Active; + + TreeIter iter; + if (comboProvider.GetActiveIter (out iter)) { + IDbFactory fac = storeProviders.GetValue (iter, 1) as IDbFactory; + settings.ProviderIdentifier = fac.Identifier; + } + } + + protected virtual void ShowSettings (DatabaseConnectionSettings settings, bool updateProviderCombo) + { + checkCustom.Active = settings.UseConnectionString; + entryName.Text = String.IsNullOrEmpty (settings.Name) ? String.Empty : settings.Name; + entryPassword.Text = String.IsNullOrEmpty (settings.Password) ? String.Empty : settings.Password; + spinPort.Value = settings.Port > 0 ? settings.Port : spinPort.Value; + entryServer.Text = String.IsNullOrEmpty (settings.Server) ? String.Empty : settings.Server; + entryUsername.Text = String.IsNullOrEmpty (settings.Username) ? String.Empty : settings.Username; + textConnectionString.Buffer.Text = String.IsNullOrEmpty (settings.ConnectionString) ? String.Empty : settings.ConnectionString; + comboDatabase.Entry.Text = String.IsNullOrEmpty (settings.Database) ? String.Empty : settings.Database; + spinMinPoolSize.Value = settings.MinPoolSize; + spinMaxPoolSize.Value = settings.MaxPoolSize; + + if (updateProviderCombo) { + TreeIter iter; + if (storeProviders.GetIterFirst (out iter)) { + do { + IDbFactory fac = storeProviders.GetValue (iter, 1) as IDbFactory; + if (settings.ProviderIdentifier == fac.Identifier) { + comboProvider.SetActiveIter (iter); + return; + } + } while (storeProviders.IterNext (ref iter)); + } + } + } + + protected virtual void ProviderChanged (object sender, System.EventArgs e) + { + TreeIter iter; + if (comboProvider.GetActiveIter (out iter)) { + IDbFactory fac = storeProviders.GetValue (iter, 1) as IDbFactory; + + bool prevDefaultSettings = isDefaultSettings; + if (isDefaultSettings) { + DatabaseConnectionSettings defaultSettings = fac.GetDefaultConnectionSettings (); + ShowSettings (defaultSettings, false); + } + + SetWidgetStates (fac); + CheckSettings (); + isDefaultSettings = prevDefaultSettings; + } + } + + protected virtual void SetWidgetStates (IDbFactory fac) + { + ConnectionSettingsCapabilities csc = (ConnectionSettingsCapabilities)fac.GetCapabilities ("ConnectionSettings", SchemaActions.Schema); + + enableServerEntry = (csc & ConnectionSettingsCapabilities.Server) == ConnectionSettingsCapabilities.Server; + enablePortEntry = (csc & ConnectionSettingsCapabilities.Port) == ConnectionSettingsCapabilities.Port; + enableUsernameEntry = (csc & ConnectionSettingsCapabilities.Username) == ConnectionSettingsCapabilities.Username; + enablePasswordEntry = (csc & ConnectionSettingsCapabilities.Password) == ConnectionSettingsCapabilities.Password; + enableOpenButton = (csc & ConnectionSettingsCapabilities.SelectDatabase) == ConnectionSettingsCapabilities.SelectDatabase; + enableRefreshButton = (csc & ConnectionSettingsCapabilities.ListDatabases) == ConnectionSettingsCapabilities.ListDatabases; + + entryServer.Sensitive = enableServerEntry; + spinPort.Sensitive = enablePortEntry; + entryUsername.Sensitive = enableUsernameEntry; + entryPassword.Sensitive = enablePasswordEntry; + buttonOpen.Sensitive = enableOpenButton && !isCreateDbMode; + buttonRefresh.Sensitive = enableRefreshButton && !isCreateDbMode; + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Dialogs/SelectColumnDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Dialogs/SelectColumnDialog.cs new file mode 100644 index 0000000000..ec95b76cc0 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Dialogs/SelectColumnDialog.cs @@ -0,0 +1,85 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; + +namespace MonoDevelop.Database.Components +{ + public partial class SelectColumnDialog : Gtk.Dialog + { + private SelectColumnWidget selecter; + + public SelectColumnDialog (bool showCheckBoxes, ColumnSchemaCollection columns) + { + this.Build(); + + selecter = new SelectColumnWidget (showCheckBoxes); + selecter.Initialize (columns); + selecter.ColumnToggled += new EventHandler (OnColumnToggled); + + hboxContent.PackStart (selecter, true, true, 0); + + ShowAll (); + } + + public ColumnSchema SelectedColumn { + get { return selecter.SelectedColumn; } + } + + public IEnumerable<ColumnSchema> CheckedColumns { + get { return selecter.CheckedColumns; } + } + + protected virtual void CancelClicked (object sender, System.EventArgs e) + { + Respond (ResponseType.Cancel); + Destroy (); + } + + protected virtual void OkClicked (object sender, EventArgs e) + { + Respond (ResponseType.Ok); + Destroy (); + } + + protected virtual void DeselectAllClicked (object sender, EventArgs e) + { + selecter.DeselectAll (); + } + + protected virtual void SelectAllClicked (object sender, EventArgs e) + { + selecter.SelectAll (); + } + + protected virtual void OnColumnToggled (object sender, EventArgs e) + { + buttonOk.Sensitive = selecter.IsColumnChecked; + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Dialogs/ShowImageDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Dialogs/ShowImageDialog.cs new file mode 100644 index 0000000000..d805434603 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Dialogs/ShowImageDialog.cs @@ -0,0 +1,50 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Components +{ + public partial class ShowImageDialog : Gtk.Dialog + { + public ShowImageDialog (Gdk.Pixbuf pixbuf) + { + this.Build(); + + //FIXME: + //if (pixbuf == null) + // hboxWarning.Visible = true; + //else + image.Pixbuf = pixbuf; + } + + protected virtual void CloseClicked (object sender, System.EventArgs e) + { + Destroy (); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Dialogs/ShowTextDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Dialogs/ShowTextDialog.cs new file mode 100644 index 0000000000..07d2cdbf38 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Dialogs/ShowTextDialog.cs @@ -0,0 +1,70 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using GtkSourceView; +using System; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Components +{ + public partial class ShowTextDialog : Gtk.Dialog + { + private SourceView sourceView; + + public ShowTextDialog (string text, string mimeType) + { + this.Build(); + + SourceLanguagesManager lm = new SourceLanguagesManager (); + SourceLanguage lang = null; + + if (String.IsNullOrEmpty (mimeType)) + lang = lm.GetLanguageFromMimeType (mimeType); + + SourceBuffer buf = null; + if (lang == null) { + SourceTagTable table = new SourceTagTable (); + buf = new SourceBuffer (table); + } else { + buf = new SourceBuffer (lang); + buf.Highlight = true; + } + sourceView = new SourceView (buf); + sourceView.ShowLineNumbers = true; + sourceView.Editable = false; + + vboxContent.PackStart (sourceView, true, true, 0); + vboxContent.ShowAll (); + if (text != null) + sourceView.Buffer.Text = text; + } + + protected virtual void CloseClicked (object sender, System.EventArgs e) + { + Destroy (); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Dialogs/WaitDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Dialogs/WaitDialog.cs new file mode 100644 index 0000000000..b85bb6dca0 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Dialogs/WaitDialog.cs @@ -0,0 +1,99 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; + +namespace MonoDevelop.Database.Components +{ + public partial class WaitDialog : Window + { + private static WaitDialog dlg; + private static bool isRunning; + + protected WaitDialog () : + base (WindowType.Popup) + { + this.KeepAbove = true; + this.Build(); + } + + public static void ShowDialog () + { + ShowDialog (null); + } + + public static void ShowDialog (string text) + { + if (dlg == null) + dlg = new WaitDialog (); + + if (text == null) + dlg.label.Markup = GettextCatalog.GetString ("Please Wait"); + else + dlg.label.Markup = text; + + dlg.ShowAll (); + if (!isRunning) { + isRunning = true; + ThreadPool.QueueUserWorkItem (new WaitCallback (ProgressUpdate)); + } else { + dlg.Present (); + } + } + + private static void ProgressUpdate (object state) + { + while (isRunning) { + DispatchService.GuiDispatch (delegate () { + dlg.progressbar.Pulse (); + }); + Thread.Sleep (1000); + } + } + + public static void HideDialog () + { + if (dlg == null) + return; + + isRunning = false; + dlg.Destroy (); + dlg = null; + } + + protected override bool OnExposeEvent (Gdk.EventExpose ev) + { + base.OnExposeEvent (ev); + Requisition req = SizeRequest (); + Style.PaintFlatBox (this.Style, this.GdkWindow, StateType.Normal, ShadowType.Out, Gdk.Rectangle.Zero, this, "tooltip", 0, 0, req.Width, req.Height); + return true; + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Makefile.am b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Makefile.am new file mode 100644 index 0000000000..6e9c64a83e --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Makefile.am @@ -0,0 +1,96 @@ +ADDIN_BUILD = $(top_builddir)/build/AddIns/MonoDevelop.Database +ASSEMBLY = $(ADDIN_BUILD)/MonoDevelop.Database.Components.dll +REFS = \ + $(GLIB_SHARP_LIBS) \ + $(GTK_SHARP_LIBS) \ + $(GTKSOURCEVIEW_SHARP_LIBS) \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Sql.dll \ + -r:$(top_builddir)/build/bin/Mono.Addins.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Components.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.Gui.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Ide.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Projects.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Projects.Gui.dll \ + -r:Mono.Posix \ + -r:System \ + -r:System.Data \ + -r:System.Xml + +FILES = \ + Codons/DataGridContentRendererCodon.cs \ + Commands/DataGridCommands.cs \ + Commands/SqlEditorCommands.cs \ + Containers/ColumnContainer.cs \ + Containers/ConditionContainer.cs \ + Containers/ParameterContainer.cs \ + Containers/SchemaContainers.cs \ + Dialogs/DatabaseConnectionSettingsDialog.cs \ + Dialogs/SelectColumnDialog.cs \ + Dialogs/ShowImageDialog.cs \ + Dialogs/ShowTextDialog.cs \ + Dialogs/WaitDialog.cs \ + gtk-gui/generated.cs \ + gtk-gui/MonoDevelop.Database.Components.DatabaseConnectionSettingsDialog.cs \ + gtk-gui/MonoDevelop.Database.Components.DataGrid.cs \ + gtk-gui/MonoDevelop.Database.Components.SelectColumnDialog.cs \ + gtk-gui/MonoDevelop.Database.Components.ShowImageDialog.cs \ + gtk-gui/MonoDevelop.Database.Components.ShowTextDialog.cs \ + gtk-gui/MonoDevelop.Database.Components.SqlEditorWidget.cs \ + gtk-gui/MonoDevelop.Database.Components.WaitDialog.cs \ + Widgets/CellRendererTypeCombo.cs \ + Widgets/ColumnMappingWidget.cs \ + Widgets/DatabaseConnectionContextComboBox.cs \ + Widgets/DataGrid/DataGrid.cs \ + Widgets/DataGrid/DataGridColumn.cs \ + Widgets/DataGrid/Renderers/BlobContentRenderer.cs \ + Widgets/DataGrid/Renderers/BooleanContentRenderer.cs \ + Widgets/DataGrid/Renderers/ByteContentRenderer.cs \ + Widgets/DataGrid/Renderers/DecimalContentRenderer.cs \ + Widgets/DataGrid/Renderers/DoubleContentRenderer.cs \ + Widgets/DataGrid/Renderers/FloatContentRenderer.cs \ + Widgets/DataGrid/Renderers/IDataGridContentRenderer.cs \ + Widgets/DataGrid/Renderers/IntegerContentRenderer.cs \ + Widgets/DataGrid/Renderers/LongContentRenderer.cs \ + Widgets/DataGrid/Renderers/NullContentRenderer.cs \ + Widgets/DataGrid/Renderers/ObjectContentRenderer.cs \ + Widgets/DataGrid/Renderers/StringContentRenderer.cs \ + Widgets/DataGrid/Visualizers/AbstractDataGridVisualizer.cs \ + Widgets/DataGrid/Visualizers/DataGridItemCommandHandler.cs \ + Widgets/DataGrid/Visualizers/IDataGridVisualizer.cs \ + Widgets/DataGrid/Visualizers/ImageVisualizer.cs \ + Widgets/DataGrid/Visualizers/TextVisualizer.cs \ + Widgets/DataGrid/Visualizers/XmlTextVisualizer.cs \ + Widgets/DataGrid/Visualizers/XmlTreeVisualizer.cs \ + Widgets/ProjectDirectoryComboBox.cs \ + Widgets/SchemaMappingWidget.cs \ + Widgets/SelectColumnWidget.cs \ + Widgets/SelectSchemaWidget.cs \ + Widgets/SortedColumnListStore.cs \ + Widgets/SqlEditorWidget.cs + +RES = \ + gtk-gui/gui.stetic \ + gtk-gui/objects.xml \ + MonoDevelop.Database.Components.addin.xml + +if ENABLE_DATABASE +all: $(ASSEMBLY) +else
+all:
+endif + +$(ASSEMBLY): $(FILES) $(build_resources) + mkdir -p $(ADDIN_BUILD) + $(CSC) $(CSC_FLAGS) $(REFS) $(build_resources:%=/resource:%) $(build_sources) -out:$@ -target:library + + +if ENABLE_DATABASE +assemblydir = $(MD_ADDIN_DIR)/MonoDevelop.Database +assembly_DATA = $(ASSEMBLY) +endif + +CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb +EXTRA_DIST = $(FILES) $(RES) + +include $(top_srcdir)/Makefile.include diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/MonoDevelop.Database.Components.addin.xml b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/MonoDevelop.Database.Components.addin.xml new file mode 100644 index 0000000000..c7a853d0aa --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/MonoDevelop.Database.Components.addin.xml @@ -0,0 +1,62 @@ +<Addin id = "Database.Components" + namespace = "MonoDevelop" + name = "MonoDevelop Database Components" + author = "Ben Motmans" + copyright = "MIT X11" + url = "http://www.monodevelop.com" + description = "Database Components Module" + version = "0.17.0"> + + <Runtime> + <Import assembly="MonoDevelop.Database.Components.dll"/> + </Runtime> + + <Dependencies> + <Addin id="Core" version="0.17.0"/> + <Addin id="Core.Gui" version="0.17.0"/> + <Addin id="Ide" version="0.17.0"/> + <Addin id="Database.Sql" version="0.17.0"/> + </Dependencies> + + <ExtensionPoint path = "/MonoDevelop/Database/DataGrid/Renderers"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/DataGrid"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/SqlEditor"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <Extension path = "/MonoDevelop/Ide/Commands"> + <Command id = "MonoDevelop.Database.Components.DataGridCommands.VisualizeAsText" + _label = "Display content as text"/> + <Command id = "MonoDevelop.Database.Components.DataGridCommands.VisualizeAsXmlText" + _label = "Display content as xml text"/> + <Command id = "MonoDevelop.Database.Components.DataGridCommands.VisualizeAsXmlTree" + _label = "Display content as xml tree"/> + <Command id = "MonoDevelop.Database.Components.DataGridCommands.VisualizeAsImage" + _label = "Display content as image"/> + + <Command id = "MonoDevelop.Database.Components.SqlEditorCommands.ImportFromFile" + _label = "Import From File" + icon = "gtk-open"/> + <Command id = "MonoDevelop.Database.Components.SqlEditorCommands.ExportToFile" + _label = "Export To File" + icon = "gtk-save"/> + </Extension> + + <Extension path = "/MonoDevelop/Database/ContextMenu/DataGrid"> + <CommandItem id = "MonoDevelop.Database.Components.DataGridCommands.VisualizeAsText"/> + <CommandItem id = "MonoDevelop.Database.Components.DataGridCommands.VisualizeAsXmlText"/> + <CommandItem id = "MonoDevelop.Database.Components.DataGridCommands.VisualizeAsXmlTree"/> + <CommandItem id = "MonoDevelop.Database.Components.DataGridCommands.VisualizeAsImage"/> + </Extension> + + <Extension path = "/MonoDevelop/Database/ContextMenu/SqlEditor"> + <CommandItem id = "MonoDevelop.Database.Components.SqlEditorCommands.ImportFromFile"/> + <CommandItem id = "MonoDevelop.Database.Components.SqlEditorCommands.ExportToFile"/> + </Extension> +</Addin> diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/MonoDevelop.Database.Components.mdp b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/MonoDevelop.Database.Components.mdp new file mode 100644 index 0000000000..646ea3a593 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/MonoDevelop.Database.Components.mdp @@ -0,0 +1,111 @@ +<Project name="MonoDevelop.Database.Components" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assemblyKeyFile="." assembly="MonoDevelop.Database.Components" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Components" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="gtk-gui/gui.stetic" subtype="Code" buildaction="EmbedAsResource" /> + <File name="gtk-gui/generated.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialogs/SelectColumnDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Components.SelectColumnDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/ProjectDirectoryComboBox.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/SelectColumnWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/SelectSchemaWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="Containers/SchemaContainers.cs" subtype="Code" buildaction="Compile" /> + <File name="Containers/ColumnContainer.cs" subtype="Code" buildaction="Compile" /> + <File name="Containers/ParameterContainer.cs" subtype="Code" buildaction="Compile" /> + <File name="Containers/ConditionContainer.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/ColumnMappingWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/SchemaMappingWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/CellRendererTypeCombo.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/DataGridColumn.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Visualizers/IDataGridVisualizer.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/DataGrid.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Components.DataGrid.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Renderers/IDataGridContentRenderer.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Renderers/StringContentRenderer.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Renderers/ObjectContentRenderer.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Renderers/NullContentRenderer.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Renderers/BooleanContentRenderer.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Renderers/IntegerContentRenderer.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Renderers/LongContentRenderer.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Renderers/DecimalContentRenderer.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Renderers/FloatContentRenderer.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Renderers/DoubleContentRenderer.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Renderers/ByteContentRenderer.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Renderers/BlobContentRenderer.cs" subtype="Code" buildaction="Compile" /> + <File name="Codons/DataGridContentRendererCodon.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialogs/ShowImageDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Components.ShowImageDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialogs/ShowTextDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Components.ShowTextDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Visualizers/TextVisualizer.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Visualizers/ImageVisualizer.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Visualizers/XmlTextVisualizer.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Visualizers/XmlTreeVisualizer.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialogs/DatabaseConnectionSettingsDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Components.DatabaseConnectionSettingsDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialogs/WaitDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Components.WaitDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DatabaseConnectionContextComboBox.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/SqlEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Components.SqlEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="Commands/SqlEditorCommands.cs" subtype="Code" buildaction="Compile" /> + <File name="Commands/DataGridCommands.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Visualizers/AbstractDataGridVisualizer.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/DataGrid/Visualizers/DataGridItemCommandHandler.cs" subtype="Code" buildaction="Compile" /> + <File name="MonoDevelop.Database.Components.addin.xml" subtype="Code" buildaction="EmbedAsResource" /> + <File name="gtk-gui/objects.xml" subtype="Code" buildaction="EmbedAsResource" /> + <File name="Widgets/SortedColumnListStore.cs" subtype="Code" buildaction="Compile" /> + <File name="Makefile.am" subtype="Code" buildaction="Nothing" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" /> + <ProjectReference type="Gac" localcopy="True" refto="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core" /> + <ProjectReference type="Gac" localcopy="True" refto="gtksourceview-sharp, Version=1.0.0.2, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Sql" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core.Gui" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Components" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Ide" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Projects" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Projects.Gui" /> + <ProjectReference type="Project" localcopy="False" refto="Mono.Addins" /> + <ProjectReference type="Gac" localcopy="True" refto="glib-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="pango-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="atk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + </References> + <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am" BuildTargetName="" CleanTargetName="" SyncReferences="True" IsAutotoolsProject="True" RelativeConfigureInPath="../../../"> + <BuildFilesVar Sync="True" Name="FILES" /> + <DeployFilesVar /> + <ResourcesVar Sync="True" Name="RES" /> + <OthersVar /> + <GacRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <AsmRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <ProjectRefVar Sync="True" Name="REFS" Prefix="-r:" /> + </MonoDevelop.Autotools.MakefileInfo> + <GtkDesignInfo isWidgetLibrary="True"> + <ExportedWidgets> + <Widget>MonoDevelop.Database.Components.ProjectDirectoryComboBox</Widget> + <Widget>MonoDevelop.Database.Components.ColumnMappingWidget</Widget> + <Widget>MonoDevelop.Database.Components.ConnectionComboBox</Widget> + <Widget>MonoDevelop.Database.Components.DatabaseConnectionContextComboBox</Widget> + <Widget>MonoDevelop.Database.Components.SelectColumnWidget</Widget> + <Widget>MonoDevelop.Database.Components.SqlEditorWidget</Widget> + </ExportedWidgets> + </GtkDesignInfo> +</Project>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/CellRendererTypeCombo.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/CellRendererTypeCombo.cs new file mode 100644 index 0000000000..a751b0d57a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/CellRendererTypeCombo.cs @@ -0,0 +1,59 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; + +namespace MonoDevelop.Database.Components +{ + public class CellRendererTypeCombo : CellRendererCombo + { + private ListStore store; + + public CellRendererTypeCombo () + { + store = new ListStore (typeof (string), typeof (Type)); + + store.AppendValues ("bool", typeof (bool)); + store.AppendValues ("byte array", typeof (byte[])); + store.AppendValues ("char", typeof (char)); + store.AppendValues ("date/time", typeof (DateTime)); + store.AppendValues ("decimal", typeof (decimal)); + store.AppendValues ("double", typeof (double)); + //TODO: store.AppendValues ("enum", typeof (Enum)); + store.AppendValues ("short", typeof (short)); + store.AppendValues ("integer", typeof (int)); + store.AppendValues ("long", typeof (long)); + store.AppendValues ("unsigned short", typeof (ushort)); + store.AppendValues ("unsigned integer", typeof (uint)); + store.AppendValues ("unsigned long", typeof (ulong)); + store.AppendValues ("float", typeof (float)); + + Model = store; + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/ColumnMappingWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/ColumnMappingWidget.cs new file mode 100644 index 0000000000..8ac2f77492 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/ColumnMappingWidget.cs @@ -0,0 +1,242 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections.Generic;using MonoDevelop.Database.Sql; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public class ColumnMappingWidget : ScrolledWindow + { + private TreeView list; + private ListStore store; + + private const int columnSelected = 0; + private const int columnObj = 1; + + public ColumnMappingWidget (bool showCheckBoxes) + { + store = new ListStore (typeof (bool), typeof (ColumnContainer)); + list = new TreeView (store); + + TreeViewColumn colName = new TreeViewColumn (); + colName.Title = GettextCatalog.GetString ("Name"); + + CellRendererToggle toggleRenderer = new CellRendererToggle (); + toggleRenderer.Activatable = true; + toggleRenderer.Toggled += new ToggledHandler (SelectToggled); + colName.PackStart (toggleRenderer, false); + CellRendererText nameRenderer = new CellRendererText (); + colName.PackStart (nameRenderer, true); + + TreeViewColumn colType = new TreeViewColumn (); + colType.Title = GettextCatalog.GetString ("Type"); + CellRendererText typeRenderer = new CellRendererText (); + colType.PackStart (typeRenderer, true); + + TreeViewColumn colPropName = new TreeViewColumn (); + colPropName.Title = GettextCatalog.GetString ("Property Name"); + CellRendererText propNameRenderer = new CellRendererText (); + propNameRenderer.Editable = true; + propNameRenderer.Edited += new EditedHandler (PropNameEdited); + colPropName.PackStart (propNameRenderer, true); + + TreeViewColumn colPropType = new TreeViewColumn (); + colPropType.Title = GettextCatalog.GetString ("Property Type"); + CellRendererTypeCombo propTypeRenderer = new CellRendererTypeCombo (); + colPropType.PackStart (propTypeRenderer, true); + + TreeViewColumn colNullable = new TreeViewColumn (); + colNullable.Title = GettextCatalog.GetString ("Nullable"); + CellRendererToggle nullableRenderer = new CellRendererToggle (); + colNullable.PackStart (nullableRenderer, false); + + TreeViewColumn colSetter = new TreeViewColumn (); + colSetter.Title = GettextCatalog.GetString ("Create Setter"); + CellRendererToggle setterRenderer = new CellRendererToggle (); + setterRenderer.Activatable = true; + setterRenderer.Toggled += new ToggledHandler (SetterToggled); + colSetter.PackStart (setterRenderer, false); + + TreeViewColumn colCtor = new TreeViewColumn (); + colCtor.Title = GettextCatalog.GetString ("Ctor Parameter"); + CellRendererToggle ctorParamRenderer = new CellRendererToggle (); + ctorParamRenderer.Activatable = true; + ctorParamRenderer.Toggled += new ToggledHandler (CtorParamToggled); + colCtor.PackStart (ctorParamRenderer, false); + + colName.SetCellDataFunc (nameRenderer, new CellLayoutDataFunc (NameDataFunc)); + colType.SetCellDataFunc (typeRenderer, new CellLayoutDataFunc (TypeDataFunc)); + colPropName.SetCellDataFunc (propNameRenderer, new CellLayoutDataFunc (PropNameDataFunc)); + colPropType.SetCellDataFunc (propTypeRenderer, new CellLayoutDataFunc (PropTypeDataFunc)); + colNullable.SetCellDataFunc (nullableRenderer, new CellLayoutDataFunc (NullableDataFunc)); + colSetter.SetCellDataFunc (setterRenderer, new CellLayoutDataFunc (SetterDataFunc)); + colCtor.SetCellDataFunc (ctorParamRenderer, new CellLayoutDataFunc (CtorDataFunc)); + + list.AppendColumn (colName); + list.AppendColumn (colType); + list.AppendColumn (colPropName); + list.AppendColumn (colPropType); + list.AppendColumn (colNullable); + list.AppendColumn (colSetter); + list.AppendColumn (colCtor); + list.HeadersVisible = true; + + this.Add (list); + } + + public void Append (IEnumerable<ColumnContainer> columns) + { + foreach (ColumnContainer column in columns) { + //TODO: make up a nice property name + store.AppendValues (true, column); + } + } + + public IEnumerable<ColumnContainer> CheckedColumns { + get { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + bool chk = (bool)store.GetValue (iter, columnSelected); + if (chk) + yield return store.GetValue (iter, columnObj) as ColumnContainer; + } while (store.IterNext (ref iter)); + } + } + } + + public void SelectAll () + { + SetSelectState (true); + } + + public void DeselectAll () + { + SetSelectState (false); + } + + private void SetSelectState (bool state) + { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + store.SetValue (iter, columnSelected, state); + } while (store.IterNext (ref iter)); + } + } + + private void NameDataFunc (CellLayout layout, CellRenderer cell, TreeModel model, TreeIter iter) + { + CellRendererText textRenderer = cell as CellRendererText; + ColumnContainer container = model.GetValue (iter, columnObj) as ColumnContainer; + textRenderer.Text = container.ColumnSchema.Name; + } + + private void TypeDataFunc (CellLayout layout, CellRenderer cell, TreeModel model, TreeIter iter) + { + CellRendererText textRenderer = cell as CellRendererText; + ColumnContainer container = model.GetValue (iter, columnObj) as ColumnContainer; + textRenderer.Text = container.ColumnSchema.DataTypeName; + } + + private void PropNameDataFunc (CellLayout layout, CellRenderer cell, TreeModel model, TreeIter iter) + { + CellRendererText textRenderer = cell as CellRendererText; + ColumnContainer container = model.GetValue (iter, columnObj) as ColumnContainer; + textRenderer.Text = container.PropertyName; + } + + private void PropTypeDataFunc (CellLayout layout, CellRenderer cell, TreeModel model, TreeIter iter) + { + //TODO: map the DB datatype to a .NET datatype + } + + private void NullableDataFunc (CellLayout layout, CellRenderer cell, TreeModel model, TreeIter iter) + { + CellRendererToggle toggleRenderer = cell as CellRendererToggle; + ColumnContainer container = model.GetValue (iter, columnObj) as ColumnContainer; + toggleRenderer.Active = container.ColumnSchema.IsNullable; + } + + private void SetterDataFunc (CellLayout layout, CellRenderer cell, TreeModel model, TreeIter iter) + { + CellRendererToggle toggleRenderer = cell as CellRendererToggle; + ColumnContainer container = model.GetValue (iter, columnObj) as ColumnContainer; + toggleRenderer.Active = container.HasSetter; + } + + private void CtorDataFunc (CellLayout layout, CellRenderer cell, TreeModel model, TreeIter iter) + { + CellRendererToggle toggleRenderer = cell as CellRendererToggle; + ColumnContainer container = model.GetValue (iter, columnObj) as ColumnContainer; + toggleRenderer.Active = container.IsCtorParameter; + } + + private void SelectToggled (object sender, ToggledArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + bool val = (bool) store.GetValue (iter, columnSelected); + store.SetValue (iter, columnSelected, !val); + } + } + + private void SetterToggled (object sender, ToggledArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + ColumnContainer container = store.GetValue (iter, columnObj) as ColumnContainer; + container.HasSetter = !container.HasSetter; + } + } + + private void CtorParamToggled (object sender, ToggledArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + ColumnContainer container = store.GetValue (iter, columnObj) as ColumnContainer; + container.IsCtorParameter = !container.IsCtorParameter; + } + } + + private void PropNameEdited (object sender, EditedArgs args) + { + Gtk.TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + ColumnContainer container = store.GetValue (iter, columnObj) as ColumnContainer; + + if (args.NewText != null && args.NewText.Length > 0) { + container.PropertyName = args.NewText; + } else { + //restore old name if new one is empty + (sender as CellRendererText).Text = container.PropertyName; + } + } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/DataGrid.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/DataGrid.cs new file mode 100644 index 0000000000..61c3f29750 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/DataGrid.cs @@ -0,0 +1,440 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; +using MonoDevelop.Ide; +using MonoDevelop.Ide.Gui; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.Components +{ + public partial class DataGrid : Bin, ICommandDelegatorRouter + { + private bool limitPageSize = true; + private int pageSize = 50; + private int currentRecord = 0; + private int numRecords = 0; + private DataTable dataSource; + + private ListStore store; + private DataGridColumn[] columns; + private int columnCount = 0; + + private int sortColumn = 0; + private IComparer sortComparer; + + private ObjectContentRenderer defaultContentRenderer; + private Dictionary<Type, IDataGridContentRenderer> contentRenderers; + private List<IDataGridVisualizer> visualizers; + + private Dictionary<int, ConvertObjectFunc> conversionLookup = new Dictionary<int, ConvertObjectFunc> (); + private delegate string ConvertObjectFunc (object obj); + + private ConvertObjectFunc byteConvertFunc = new ConvertObjectFunc (ByteConvertFunc); + private ConvertObjectFunc sbyteConvertFunc = new ConvertObjectFunc (SByteConvertFunc); + + public DataGrid () + { + this.Build (); + + //Gtk# 2.10: grid.EnableGridLines = TreeViewGridLines.Both; + grid.ButtonPressEvent += new ButtonPressEventHandler (ButtonPressed); + + contentRenderers = new Dictionary<Type, IDataGridContentRenderer> (); + visualizers = new List<IDataGridVisualizer> (); + + AddContentRenderer (new BlobContentRenderer ()); + AddContentRenderer (new BooleanContentRenderer ()); + AddContentRenderer (new ByteContentRenderer ()); + AddContentRenderer (new DecimalContentRenderer ()); + AddContentRenderer (new DoubleContentRenderer ()); + AddContentRenderer (new FloatContentRenderer ()); + AddContentRenderer (new IntegerContentRenderer ()); + AddContentRenderer (new LongContentRenderer ()); + AddContentRenderer (new StringContentRenderer ()); + + visualizers.Add (new ImageVisualizer ()); + visualizers.Add (new TextVisualizer ()); + visualizers.Add (new XmlTextVisualizer ()); + visualizers.Add (new XmlTreeVisualizer ()); + + foreach (DataGridContentRendererCodon codon in AddinManager.GetExtensionNodes ("/MonoDevelop/Database/DataGrid/Renderers")) + AddContentRenderer (codon.ContentRenderer); + } + + public bool ShowNavigator { + get { return hbox.Visible; } + set { hbox.Visible = value; } + } + + public bool EnableNavigator { + get { return hbox.Sensitive; } + set { hbox.Sensitive = value; } + } + + public int PageSize { + get { return pageSize; } + set { pageSize = value; } + } + + public bool LimitPageSize { + get { return limitPageSize; } + set { + limitPageSize = value; + ShowNavigator = LimitPageSize; + } + } + + public int CurrentRecord { + get { return currentRecord; } + } + + public int RecordCount { + get { return numRecords; } + } + + public void DataBind () + { + if (dataSource == null) { + Clear (); + return; + } + + int index = 0; + Type[] storeTypes = new Type[dataSource.Columns.Count]; + columnCount = dataSource.Columns.Count; + foreach (DataColumn col in dataSource.Columns) { + DataGridColumn dgCol = new DataGridColumn (this, col, index); + grid.AppendColumn (dgCol); + + if (col.DataType == typeof (byte)) { + //special case for gchar (TODO: look up the bugzilla bug id) + storeTypes[index] = typeof (string); + conversionLookup.Add (index, byteConvertFunc); + } else if (col.DataType == typeof (sbyte)) { + storeTypes[index] = typeof (string); + conversionLookup.Add (index, sbyteConvertFunc); + } else if (col.DataType.IsPrimitive || col.DataType == typeof (string) || col.DataType.IsEnum) { + storeTypes[index] = col.DataType; + } else { + //the ListStore doesn't allow types that can't be converted to a GType + storeTypes[index] = typeof (object); + } + + index++; + } + store = new ListStore (storeTypes); + grid.Model = store; + + TreeIterCompareFunc sortFunc = new TreeIterCompareFunc (SortFunc); + store.SetSortFunc (0, sortFunc); + store.SetSortColumnId (0, SortType.Ascending); //TODO: is this needed ? + + NavigateToRecord (0); + } + + public DataTable DataSource { + get { return dataSource; } + set { + dataSource = value; + if (value != null) + numRecords = dataSource.Rows.Count; + else + numRecords = 0; + } + } + + public void Clear () + { + currentRecord = 0; + numRecords = 0; + columnCount = 0; + + conversionLookup.Clear (); + + if (store != null) { + store.Clear (); + store = null; + } + + if (columns != null) { + for (int i=0; i<columns.Length; i++) { + if (columns[i] != null) + grid.RemoveColumn (columns[i]); + columns[i] = null; + } + columns = null; + } + } + + public void NavigateToRecord (int record) + { + if (record < 0 || record > numRecords) + throw new ArgumentException ("Invalid record index."); + + if (limitPageSize) { + int count = numRecords - record; + if (count > pageSize) count = pageSize; + + FillGrid (record, count); + } else { + int count = numRecords - record; + FillGrid (record, count); + } + ShowNavigationState (); + } + + object ICommandDelegatorRouter.GetNextCommandTarget () + { + return null; + } + + object ICommandDelegatorRouter.GetDelegatedCommandTarget () + { +// if (dataObject != null) { +// IDataGridVisualizer[] visualizers = GetItemVisualizers (dataObject); +// if (visualizers.Length > 0) { +// DataGridItemCommandHandler[] handlers = new DataGridItemCommandHandler [visualizers.Length]; +// for (int n=0; n<visualizers.Length; n++) { +// handlers [n] = chain [n].CommandHandler; +// +// for (int n=0; n<handlers.Length; n++) { +// handlers [n].SetDataObject (dataObject); +// if (n < chain.Length - 1) +// handlers [n].SetNextTarget (handlers [n+1]); +// else +// handlers [n].SetNextTarget (null); +// } +// return handlers [0]; +// } +// } + return null; + } + + private void ShowNavigationState () + { + entryTotal.Text = numRecords.ToString (); + int currentEnd = 0; + if (limitPageSize) { + currentEnd = currentRecord + pageSize; + if (currentEnd > numRecords) + currentEnd = numRecords; + } else { + currentEnd = numRecords; + } + entryCurrent.Text = String.Format ("{0}-{1}", currentRecord, currentEnd); + } + + private void FillGrid (int start, int count) + { + grid.Model = null; + + int end = start + count; + if (dataSource.Rows.Count < end) + end = dataSource.Rows.Count; + + store.Clear (); + for (int i=start; i<end; i++) { + DataRow row = dataSource.Rows[i]; + + TreeIter iter = store.Append (); + for (int j=0;j<columnCount; j++) { + //HACK: this is a hack for a bug that doesn't allow gchars in a liststore + if (conversionLookup.ContainsKey (j)) { + ConvertObjectFunc func = conversionLookup[j]; + store.SetValue (iter, j, func (row[j])); + } else { + store.SetValue (iter, j, row[j]); + } + } + } + + grid.Model = store; + } + + protected virtual void ButtonFirstClicked (object sender, System.EventArgs e) + { + currentRecord = 0; + NavigateToRecord (currentRecord); + } + + protected virtual void ButtonPreviousClicked (object sender, System.EventArgs e) + { + currentRecord -= pageSize; + if (currentRecord < 0) currentRecord = 0; + NavigateToRecord (currentRecord); + } + + protected virtual void ButtonNextClicked (object sender, System.EventArgs e) + { + currentRecord += pageSize; + if ((currentRecord + pageSize) > numRecords) { + int modulus = numRecords % pageSize; + currentRecord = numRecords - modulus; + } + NavigateToRecord (currentRecord); + } + + protected virtual void ButtonLastClicked (object sender, System.EventArgs e) + { + int modulus = numRecords % pageSize; + currentRecord = numRecords - modulus; + NavigateToRecord (currentRecord); + } + + protected virtual void EntryCurrentActivated (object sender, System.EventArgs e) + { + string[] split = entryCurrent.Text.Split (new char[]{'-'}, 2, StringSplitOptions.RemoveEmptyEntries); + if (split == null || split.Length < 1) { + ShowNavigationState (); + return; + } + + int curRec; + int curEnd; + + if (int.TryParse (split[0], out curRec)) { + if (curRec < 0) + curRec = 0; + else if (curRec >= numRecords) + curRec = numRecords - 1; + + currentRecord = curRec; + } else { + return; + } + + if (split.Length > 1 && int.TryParse (split[1], out curEnd)) { + pageSize = curEnd - curRec; + if (pageSize <= 0) + pageSize = 50; + } + + ShowNavigationState (); + } + + internal IDataGridContentRenderer GetDataGridContentRenderer (Type type) + { + IDataGridContentRenderer renderer = null; + if (contentRenderers.TryGetValue (type, out renderer)) + return renderer; + + if (defaultContentRenderer == null) + defaultContentRenderer = new ObjectContentRenderer (); + return defaultContentRenderer; + } + + internal void Sort (DataGridColumn column) + { + sortColumn = column.ColumnIndex; + sortComparer = column.ContentComparer; + + if (column.SortIndicator) + column.SortOrder = ReverseSortOrder (column); + + //show indicator on current column, remove on all others + foreach (TreeViewColumn col in grid.Columns) + col.SortIndicator = col == column; + + store.SetSortFunc (column.ColumnIndex, new TreeIterCompareFunc (SortFunc)); + store.SetSortColumnId (column.ColumnIndex, column.SortOrder); + } + + private SortType ReverseSortOrder (TreeViewColumn column) + { + if (column.SortIndicator) { + if (column.SortOrder == SortType.Ascending) + return SortType.Descending; + else + return SortType.Ascending; + } else { + return SortType.Ascending; + } + } + + private int SortFunc (TreeModel model, TreeIter x, TreeIter y) + { + if (sortComparer == null) + return 0; + + object ox = model.GetValue (x, sortColumn); + object oy = model.GetValue (y, sortColumn); + + return sortComparer.Compare (ox, oy); + } + + private void AddContentRenderer (IDataGridContentRenderer renderer) + { + foreach (Type type in renderer.DataTypes) { + if (contentRenderers.ContainsKey (type)) + LoggingService.LogError ("Duplicate IDataGridContentRenderer for type '{0}'", type.FullName); + else + contentRenderers.Add (type, renderer); + } + } + + [GLib.ConnectBefore] + private void ButtonPressed (object sender, ButtonPressEventArgs args) + { + if (args.Event.Button == 3) { + TreePath path = null; + TreeViewColumn col = null; + if (grid.GetPathAtPos ((int)args.Event.X, (int)args.Event.Y, out path, out col)) { + //DataGridColumn dgCol = col as DataGridColumn; + TreeIter iter; + if (store.GetIter (out iter, path)) { + //dataObject = store.GetValue (iter, dgCol.ColumnIndex); + + IdeApp.CommandService.ShowContextMenu ("/MonoDevelop/Database/ContextMenu/DataGrid"); + } + } + } + } + + private static string ByteConvertFunc (object obj) + { + if (Convert.IsDBNull (obj) || obj == null) + return null; + + byte b = (byte)obj; + return "0x" + b.ToString ("X"); + } + + private static string SByteConvertFunc (object obj) + { + if (Convert.IsDBNull (obj) || obj == null) + return null; + + sbyte b = (sbyte)obj; + return b.ToString ("N"); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/DataGridColumn.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/DataGridColumn.cs new file mode 100644 index 0000000000..49d3ff739f --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/DataGridColumn.cs @@ -0,0 +1,93 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Data; +using System.Collections; +using System.Collections.Generic; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public class DataGridColumn : TreeViewColumn + { + private DataGrid grid; + private DataColumn column; + private int columnIndex; + private IDataGridContentRenderer contentRenderer; + private static IDataGridContentRenderer nullRenderer; + + static DataGridColumn () + { + nullRenderer = new NullContentRenderer (); + } + + public DataGridColumn (DataGrid grid, DataColumn column, int columnIndex) + { + this.grid = grid; + this.column = column; + this.columnIndex = columnIndex; + + contentRenderer = grid.GetDataGridContentRenderer (column.DataType); + + Title = column.ColumnName.Replace ("_", "__"); //underscores are normally used for underlining, so needs escape char + Clickable = true; + + CellRendererText textRenderer = new CellRendererText (); + PackStart (textRenderer, true); + SetCellDataFunc (textRenderer, new CellLayoutDataFunc (ContentDataFunc)); + } + + public int ColumnIndex { + get { return columnIndex; } + } + + public IComparer ContentComparer { + get { return contentRenderer; } + } + + public Type DataType { + get { return column.DataType; } + } + + private void ContentDataFunc (CellLayout layout, CellRenderer cell, TreeModel model, TreeIter iter) + { + object dataObject = model.GetValue (iter, columnIndex); + if (dataObject == null) + nullRenderer.SetContent (cell as CellRendererText, dataObject); + else + contentRenderer.SetContent (cell as CellRendererText, dataObject); + } + + protected override void OnClicked () + { + base.OnClicked (); + grid.Sort (this); + } + + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/BlobContentRenderer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/BlobContentRenderer.cs new file mode 100644 index 0000000000..663dd52e89 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/BlobContentRenderer.cs @@ -0,0 +1,51 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public class BlobContentRenderer : IDataGridContentRenderer + { + public Type[] DataTypes { + get { return new Type[]{ typeof(byte[]) }; } + } + + public void SetContent (CellRendererText cell, object dataObject) + { + cell.Markup = "<u>bin</u>"; + } + + public int Compare (object x, object y) + { + return 0; + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/BooleanContentRenderer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/BooleanContentRenderer.cs new file mode 100644 index 0000000000..6c603fdb24 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/BooleanContentRenderer.cs @@ -0,0 +1,57 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public class BooleanContentRenderer : IDataGridContentRenderer + { + public Type[] DataTypes { + get { return new Type[]{ typeof(bool) }; } + } + + public void SetContent (CellRendererText cell, object dataObject) + { + bool b = (bool)dataObject; + cell.Text = b ? GettextCatalog.GetString ("Y") : GettextCatalog.GetString ("N"); + } + + public int Compare (object x, object y) + { + if (x == null && y == null) return 0; + else if (x == null) return -1; + else if (y == null) return 1; + + bool bx = (bool)x; + return bx.CompareTo (y); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/ByteContentRenderer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/ByteContentRenderer.cs new file mode 100644 index 0000000000..e80833d189 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/ByteContentRenderer.cs @@ -0,0 +1,56 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public class ByteContentRenderer : IDataGridContentRenderer + { + public Type[] DataTypes { + get { return new Type[]{ typeof(byte), typeof(sbyte) }; } + } + + public void SetContent (CellRendererText cell, object dataObject) + { + cell.Text = dataObject.ToString (); + } + + public int Compare (object x, object y) + { + if (x == null && y == null) return 0; + else if (x == null) return -1; + else if (y == null) return 1; + + byte bx = (byte)x; + return bx.CompareTo (y); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/DecimalContentRenderer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/DecimalContentRenderer.cs new file mode 100644 index 0000000000..aab4d3f92a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/DecimalContentRenderer.cs @@ -0,0 +1,56 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public class DecimalContentRenderer : IDataGridContentRenderer + { + public Type[] DataTypes { + get { return new Type[]{ typeof(decimal) }; } + } + + public void SetContent (CellRendererText cell, object dataObject) + { + cell.Text = dataObject.ToString (); + } + + public int Compare (object x, object y) + { + if (x == null && y == null) return 0; + else if (x == null) return -1; + else if (y == null) return 1; + + decimal dx = (decimal)x; + return dx.CompareTo (y); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/DoubleContentRenderer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/DoubleContentRenderer.cs new file mode 100644 index 0000000000..f98fed5948 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/DoubleContentRenderer.cs @@ -0,0 +1,56 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public class DoubleContentRenderer : IDataGridContentRenderer + { + public Type[] DataTypes { + get { return new Type[]{ typeof(double) }; } + } + + public void SetContent (CellRendererText cell, object dataObject) + { + cell.Text = dataObject.ToString (); + } + + public int Compare (object x, object y) + { + if (x == null && y == null) return 0; + else if (x == null) return -1; + else if (y == null) return 1; + + double dx = (double)x; + return dx.CompareTo (y); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/FloatContentRenderer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/FloatContentRenderer.cs new file mode 100644 index 0000000000..8a1c9afb38 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/FloatContentRenderer.cs @@ -0,0 +1,56 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public class FloatContentRenderer : IDataGridContentRenderer + { + public Type[] DataTypes { + get { return new Type[]{ typeof(float) }; } + } + + public void SetContent (CellRendererText cell, object dataObject) + { + cell.Text = dataObject.ToString (); + } + + public int Compare (object x, object y) + { + if (x == null && y == null) return 0; + else if (x == null) return -1; + else if (y == null) return 1; + + float fx = (float)x; + return fx.CompareTo (y); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/IDataGridContentRenderer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/IDataGridContentRenderer.cs new file mode 100644 index 0000000000..0e5c3ca387 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/IDataGridContentRenderer.cs @@ -0,0 +1,41 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public interface IDataGridContentRenderer : IComparer + { + Type[] DataTypes { get; } + + void SetContent (CellRendererText cell, object dataObject); + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/IntegerContentRenderer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/IntegerContentRenderer.cs new file mode 100644 index 0000000000..61d02d850d --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/IntegerContentRenderer.cs @@ -0,0 +1,56 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public class IntegerContentRenderer : IDataGridContentRenderer + { + public Type[] DataTypes { + get { return new Type[]{ typeof(int), typeof(uint), typeof(short), typeof(ushort) }; } + } + + public void SetContent (CellRendererText cell, object dataObject) + { + cell.Text = dataObject.ToString (); + } + + public int Compare (object x, object y) + { + if (x == null && y == null) return 0; + else if (x == null) return -1; + else if (y == null) return 1; + + int ix = (int)x; + return ix.CompareTo (y); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/LongContentRenderer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/LongContentRenderer.cs new file mode 100644 index 0000000000..4ad174ce57 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/LongContentRenderer.cs @@ -0,0 +1,56 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public class LongContentRenderer : IDataGridContentRenderer + { + public Type[] DataTypes { + get { return new Type[]{ typeof(long), typeof(ulong) }; } + } + + public void SetContent (CellRendererText cell, object dataObject) + { + cell.Text = dataObject.ToString (); + } + + public int Compare (object x, object y) + { + if (x == null && y == null) return 0; + else if (x == null) return -1; + else if (y == null) return 1; + + long lx = (long)x; + return lx.CompareTo (y); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/NullContentRenderer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/NullContentRenderer.cs new file mode 100644 index 0000000000..b1a518eb26 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/NullContentRenderer.cs @@ -0,0 +1,51 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public class NullContentRenderer : IDataGridContentRenderer + { + public Type[] DataTypes { + get { return Type.EmptyTypes; } //special case + } + + public void SetContent (CellRendererText cell, object dataObject) + { + cell.Markup = "<i>null</i>"; + } + + public int Compare (object x, object y) + { + return 0; + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/ObjectContentRenderer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/ObjectContentRenderer.cs new file mode 100644 index 0000000000..e382b985ac --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/ObjectContentRenderer.cs @@ -0,0 +1,57 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public class ObjectContentRenderer : IDataGridContentRenderer + { + public Type[] DataTypes { + get { return Type.EmptyTypes; } //special case + } + + public void SetContent (CellRendererText cell, object dataObject) + { + cell.Text = dataObject.ToString (); + } + + public int Compare (object x, object y) + { + if (x == null && y == null) return 0; + else if (x == null) return -1; + else if (y == null) return 1; + + if (x is IComparable) + return (x as IComparable).CompareTo (y); + return 0; + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/StringContentRenderer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/StringContentRenderer.cs new file mode 100644 index 0000000000..8b430f81c2 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Renderers/StringContentRenderer.cs @@ -0,0 +1,56 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public class StringContentRenderer : IDataGridContentRenderer + { + public Type[] DataTypes { + get { return new Type[]{ typeof(string) }; } + } + + public void SetContent (CellRendererText cell, object dataObject) + { + cell.Text = dataObject.ToString (); + } + + public int Compare (object x, object y) + { + if (x == null && y == null) return 0; + else if (x == null) return -1; + else if (y == null) return 1; + + string sx = (string)x; + return sx.CompareTo (y); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/AbstractDataGridVisualizer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/AbstractDataGridVisualizer.cs new file mode 100644 index 0000000000..6e74d0dfc2 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/AbstractDataGridVisualizer.cs @@ -0,0 +1,55 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public abstract class AbstractDataGridVisualizer : IDataGridVisualizer + { + protected DataGridItemCommandHandler commandHandler; + + public virtual bool CanVisualize (Type type) + { + return false; + } + + public virtual Type CommandHandlerType { + get { return typeof (DataGridItemCommandHandler); } + } + + public virtual DataGridItemCommandHandler CommandHandler { + get { + if (commandHandler == null) + commandHandler = (DataGridItemCommandHandler) Activator.CreateInstance (CommandHandlerType); + return commandHandler; + } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/DataGridItemCommandHandler.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/DataGridItemCommandHandler.cs new file mode 100644 index 0000000000..af7a402a36 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/DataGridItemCommandHandler.cs @@ -0,0 +1,65 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Data; +using System.Collections; +using System.Collections.Generic; +using Mono.Addins; +using MonoDevelop.Core; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.Components +{ + public class DataGridItemCommandHandler : ICommandRouter + { + private object nextTarget; + private object dataObject; + + internal void SetDataObject (object dataObject) + { + this.dataObject = dataObject; + } + + internal void SetNextTarget (object nextTarget) + { + this.nextTarget = nextTarget; + } + + object ICommandRouter.GetNextCommandTarget () + { + return nextTarget; + } + + protected object DataObject { + get { return dataObject; } + } + + public virtual void ActivateItem () + { + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/IDataGridVisualizer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/IDataGridVisualizer.cs new file mode 100644 index 0000000000..259eb71a51 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/IDataGridVisualizer.cs @@ -0,0 +1,41 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public interface IDataGridVisualizer + { + bool CanVisualize (Type type); + + Type CommandHandlerType { get; } + DataGridItemCommandHandler CommandHandler { get; } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/ImageVisualizer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/ImageVisualizer.cs new file mode 100644 index 0000000000..1247e1dab9 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/ImageVisualizer.cs @@ -0,0 +1,61 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public class ImageVisualizer : AbstractDataGridVisualizer + { + public override bool CanVisualize (Type type) + { + return type == typeof (byte[]); + } + + public override Type CommandHandlerType { + get { return typeof (ImageVisualizerCommandHandler); } + } + } + + public class ImageVisualizerCommandHandler : DataGridItemCommandHandler + { + public override void ActivateItem () + { + byte[] blob = DataObject as byte[]; + + Gdk.Pixbuf pixbuf = null; + try { + pixbuf = new Gdk.Pixbuf (blob); + } catch {} + + using (ShowImageDialog dlg = new ShowImageDialog (pixbuf)) + dlg.Run (); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/TextVisualizer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/TextVisualizer.cs new file mode 100644 index 0000000000..ac5a7481d3 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/TextVisualizer.cs @@ -0,0 +1,59 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public class TextVisualizer : AbstractDataGridVisualizer + { + public override bool CanVisualize (Type type) + { + return type == typeof (string) || type == typeof (byte[]); + } + +// public virtual void ShowContent (object dataObject) +// { +// string txt = GetContent (dataObject); +// +// using (ShowTextDialog dlg = new ShowTextDialog (txt, "text/plain")) +// dlg.Run (); +// } + + protected virtual string GetContent (object dataObject) + { + if (dataObject == null) + return null; + else if (dataObject is Byte[]) + return System.Text.Encoding.UTF8.GetString (dataObject as byte[]); + else + return dataObject.ToString (); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/XmlTextVisualizer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/XmlTextVisualizer.cs new file mode 100644 index 0000000000..264d7d8e1b --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/XmlTextVisualizer.cs @@ -0,0 +1,44 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public class XmlTextVisualizer : TextVisualizer + { +// public void ShowContent (object dataObject) +// { +// string txt = GetContent (dataObject); +// +// using (ShowTextDialog dlg = new ShowTextDialog (txt, "text/xml")) +// dlg.Run (); +// } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/XmlTreeVisualizer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/XmlTreeVisualizer.cs new file mode 100644 index 0000000000..545d4ac3a1 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DataGrid/Visualizers/XmlTreeVisualizer.cs @@ -0,0 +1,45 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Data; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Components +{ + public class XmlTreeVisualizer : TextVisualizer + { +// public override void ShowContent (object dataObject) +// { +// string xml = GetContent (dataObject); +// +// //TODO: +// //using (ShowXmlTreeDialog dlg = new ShowXmlTreeDialog (xml)) +// // dlg.Run (); +// } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DatabaseConnectionContextComboBox.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DatabaseConnectionContextComboBox.cs new file mode 100644 index 0000000000..161f99b8b5 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/DatabaseConnectionContextComboBox.cs @@ -0,0 +1,130 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; + +namespace MonoDevelop.Database.Components +{ + public class DatabaseConnectionContextComboBox : ComboBox + { + private ListStore store; + + public DatabaseConnectionContextComboBox () + { + store = new ListStore (typeof (string), typeof (object)); + Model = store; + + CellRendererText textRenderer = new CellRendererText (); + PackStart (textRenderer, true); + AddAttribute (textRenderer, "text", 0); + + foreach (DatabaseConnectionContext context in ConnectionContextService.DatabaseConnections) + store.AppendValues (context.ConnectionSettings.Name, context); + TreeIter iter; + if (store.GetIterFirst (out iter)) + SetActiveIter (iter); + + ConnectionContextService.ConnectionContextAdded += new DatabaseConnectionContextEventHandler (OnConnectionAdded); + ConnectionContextService.ConnectionContextRemoved += new DatabaseConnectionContextEventHandler (OnConnectionRemoved); + ConnectionContextService.ConnectionContextEdited += new DatabaseConnectionContextEventHandler (OnConnectionEdited); + ConnectionContextService.ConnectionContextRefreshed += new DatabaseConnectionContextEventHandler (OnConnectionRefreshed); + } + + public DatabaseConnectionContext DatabaseConnection { + get { + TreeIter iter; + if (GetActiveIter (out iter)) + return store.GetValue (iter, 1) as DatabaseConnectionContext; + return null; + } + set { + if (value == null) + throw new ArgumentNullException ("DatabaseConnection"); + + TreeIter iter = GetTreeIter (value); + if (!iter.Equals (TreeIter.Zero)) + SetActiveIter (iter); + } + } + + public void AddDatabaseConnectionContext (DatabaseConnectionContext context) + { + if (context == null) + throw new ArgumentNullException ("context"); + + store.AppendValues (context.ConnectionSettings.Name, context); + } + + private void OnConnectionAdded (object sender, DatabaseConnectionContextEventArgs args) + { + TreeIter newIter = store.AppendValues (args.ConnectionContext.ConnectionSettings.Name, args.ConnectionContext); + TreeIter iter; + if (!GetActiveIter (out iter)) + SetActiveIter (newIter); + } + + private void OnConnectionRemoved (object sender, DatabaseConnectionContextEventArgs args) + { + TreeIter iter = GetTreeIter (args.ConnectionContext); + TreeIter selected; + if (GetActiveIter (out selected)) { + if (iter.Equals (selected)) { + store.Remove (ref iter); + if (store.GetIterFirst (out iter)) + SetActiveIter (iter); + } + } + store.Remove (ref iter); + } + + private void OnConnectionEdited (object sender, DatabaseConnectionContextEventArgs args) + { + TreeIter iter = GetTreeIter (args.ConnectionContext); + store.SetValue (iter, 0, args.ConnectionContext.ConnectionSettings.Name); + } + + private void OnConnectionRefreshed (object sender, DatabaseConnectionContextEventArgs args) + { + TreeIter iter = GetTreeIter (args.ConnectionContext); + store.SetValue (iter, 0, args.ConnectionContext.ConnectionSettings.Name); + } + + private TreeIter GetTreeIter (DatabaseConnectionContext context) + { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + object obj = store.GetValue (iter, 1); + if (obj == context) + return iter; + } while (store.IterNext (ref iter)); + } + return TreeIter.Zero; + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/ProjectDirectoryComboBox.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/ProjectDirectoryComboBox.cs new file mode 100644 index 0000000000..8c5b2421f5 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/ProjectDirectoryComboBox.cs @@ -0,0 +1,123 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Ide.Gui; +using MonoDevelop.Projects; +using MonoDevelop.Projects.Gui; + +namespace MonoDevelop.Database.Components +{ + public class ProjectDirectoryComboBox : ComboBox + { + private TreeStore store; + + public ProjectDirectoryComboBox () + { + store = new TreeStore (typeof (Gdk.Pixbuf), typeof (string), typeof (Project), typeof (ProjectFile)); + + CellRendererPixbuf pixbuf = new CellRendererPixbuf (); + CellRendererText text = new CellRendererText (); + + this.PackStart (pixbuf, false); + this.PackStart (text, false); + this.AddAttribute (pixbuf, "pixbuf", 0); + this.AddAttribute (text, "markup", 1); + + this.Model = store; + + PopulateCombo (); + } + + public string SelectedDirectory { + get { + TreeIter iter; + if (this.GetActiveIter (out iter)) { + ProjectFile file = store.GetValue (iter, 3) as ProjectFile; + if (file != null) + return file.FilePath; + + Project proj = store.GetValue (iter, 2) as Project; + return proj.BaseDirectory; + } + + return null; + } + } + + public Project SelectedProject { + get { + TreeIter iter; + if (this.GetActiveIter (out iter)) + return store.GetValue (iter, 2) as Project; + return null; + } + } + + private void PopulateCombo () + { + IconService service = (IconService) ServiceManager.GetService (typeof(IconService)); + Combine cmb = IdeApp.ProjectOperations.CurrentOpenCombine; + if (cmb != null) { + CombineEntry selected = IdeApp.ProjectOperations.CurrentSelectedCombineEntry; + TreeIter activeIter = TreeIter.Zero; + + foreach (Project proj in cmb.Entries) { + Gdk.Pixbuf pixbuf = null; + + if (proj is DotNetProject && (proj as DotNetProject).LanguageBinding == null) { + pixbuf = MonoDevelop.Core.Gui.Services.Resources.GetIcon (Stock.DialogError); + } else { + string icon = service.GetImageForProjectType (proj.ProjectType); + pixbuf = MonoDevelop.Core.Gui.Services.Resources.GetIcon (icon); + } + + TreeIter iter = store.AppendValues (pixbuf, "<b>" + proj.Name + "</b>", proj, null); + + foreach (ProjectFile file in proj.ProjectFiles) { + if (file.Subtype != Subtype.Directory) + continue; + + pixbuf = MonoDevelop.Core.Gui.Services.Resources.GetIcon (Stock.Directory); + store.AppendValues (iter, pixbuf, file.Name, proj, file); + } + + if (proj == selected) + activeIter = iter; + } + + if (activeIter.Equals (TreeIter.Zero)) { + if (store.GetIterFirst (out activeIter)) + this.SetActiveIter (activeIter); + } else { + this.SetActiveIter (activeIter); + } + } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/SchemaMappingWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/SchemaMappingWidget.cs new file mode 100644 index 0000000000..d790fb325f --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/SchemaMappingWidget.cs @@ -0,0 +1,2 @@ + +// created on 7/8/2007 at 11:21 PM
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/SelectColumnWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/SelectColumnWidget.cs new file mode 100644 index 0000000000..7041f09646 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/SelectColumnWidget.cs @@ -0,0 +1,143 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Database.Sql; + +namespace MonoDevelop.Database.Components +{ + public class SelectColumnWidget : ScrolledWindow + { + public event EventHandler ColumnToggled; + + protected TreeView list; + protected SortedColumnListStore store; + + private ColumnSchemaCollection columns; + + public SelectColumnWidget () + : this (true) + { + } + + public SelectColumnWidget (bool showCheckBoxes) + { + list = new TreeView (); + list.HeadersVisible = true; + + InitializeColumns (showCheckBoxes); + + this.Add (list); + } + + public bool SingleCheck { + get { return store.SingleCheck; } + set { + if (store == null) + return; //when init isn't called yet + store.SingleCheck = value; + } + } + + protected virtual void InitializeColumns (bool showCheckBoxes) + { + TreeViewColumn col = new TreeViewColumn (); + col.Title = GettextCatalog.GetString ("Column"); + + if (showCheckBoxes) { + CellRendererToggle toggleRenderer = new CellRendererToggle (); + toggleRenderer.Activatable = true; + toggleRenderer.Toggled += new ToggledHandler (ItemToggled); + col.PackStart (toggleRenderer, false); + col.AddAttribute (toggleRenderer, "active", SortedColumnListStore.ColSelectIndex); + } + + CellRendererText textRenderer = new CellRendererText (); + col.PackStart (textRenderer, true); + col.AddAttribute (textRenderer, "text", SortedColumnListStore.ColNameIndex); + + list.AppendColumn (col); + } + + public void Initialize (ColumnSchemaCollection columns) + { + this.columns = columns; + + store = new SortedColumnListStore (columns); + store.ColumnToggled += delegate (object sender, EventArgs args) { + if (ColumnToggled != null) + ColumnToggled (this, args); + }; + list.Model = store.Store; + } + + public ColumnSchema SelectedColumn { + get { + TreeIter iter; + if (list.Selection.GetSelected (out iter)) + return store.GetColumnSchema (iter); + return null; + } + } + + public IEnumerable<ColumnSchema> CheckedColumns { + get { return store.CheckedColumns; } + } + + public bool IsColumnChecked { + get { return store.IsColumnChecked; } + } + + public void SelectAll () + { + store.SelectAll (); + } + + public void DeselectAll () + { + store.DeselectAll (); + } + + public void Select (string name) + { + store.Select (name); + } + + public void Select (ColumnSchema column) + { + store.Select (column); + } + + private void ItemToggled (object sender, ToggledArgs args) + { + TreeIter iter; + if (store.Store.GetIterFromString (out iter, args.Path)) + store.ToggleSelect (iter); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/SelectSchemaWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/SelectSchemaWidget.cs new file mode 100644 index 0000000000..b7156c883c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/SelectSchemaWidget.cs @@ -0,0 +1,181 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; + +namespace MonoDevelop.Database.Components +{ + public class SelectSchemaWidget : ScrolledWindow + { + private TreeView list; + private ListStore store; + + private const int columnSelected = 0; + private const int columnObj = 1; + + public SelectSchemaWidget () + { + store = new ListStore (typeof (bool), typeof (ISchemaContainer)); + list = new TreeView (store); + + TreeViewColumn col = new TreeViewColumn (); + + CellRendererToggle toggleRenderer = new CellRendererToggle (); + toggleRenderer.Activatable = true; + toggleRenderer.Toggled += new ToggledHandler (ItemToggled); + col.PackStart (toggleRenderer, false); + + CellRendererPixbuf pixbufRenderer = new CellRendererPixbuf (); + col.PackStart (pixbufRenderer, false); + + CellRendererText textRenderer = new CellRendererText (); + col.PackStart (textRenderer, true); + + col.SetCellDataFunc (textRenderer, new CellLayoutDataFunc (TextDataFunc)); + col.SetCellDataFunc (pixbufRenderer, new CellLayoutDataFunc (PixbufDataFunc)); + + list.AppendColumn (col); + list.HeadersVisible = false; + + this.Add (list); + } + + public void Append (IEnumerable<TableSchema> tables) + { + if (tables == null) + throw new ArgumentNullException ("tables"); + + List<ISchemaContainer> containers = new List<ISchemaContainer> (); + foreach (TableSchema table in tables) + containers.Add (new TableSchemaContainer (table)); + PopulateList (containers); + } + + public void Append (IEnumerable<ViewSchema> views) + { + if (views == null) + throw new ArgumentNullException ("views"); + + List<ISchemaContainer> containers = new List<ISchemaContainer> (); + foreach (ViewSchema view in views) + containers.Add (new ViewSchemaContainer (view)); + PopulateList (containers); + } + + public void Append (IEnumerable<ProcedureSchema> procedures) + { + if (procedures == null) + throw new ArgumentNullException ("procedures"); + + List<ISchemaContainer> containers = new List<ISchemaContainer> (); + foreach (ProcedureSchema procedure in procedures) + containers.Add (new ProcedureSchemaContainer (procedure)); + PopulateList (containers); + } + + public IEnumerable<ISchemaContainer> CheckedSchemas { + get { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + bool chk = (bool)store.GetValue (iter, columnSelected); + if (chk) + yield return store.GetValue (iter, columnObj) as ISchemaContainer; + } while (store.IterNext (ref iter)); + } + } + } + + public void SelectAll () + { + SetSelectState (true); + } + + public void DeselectAll () + { + SetSelectState (false); + } + + private void SetSelectState (bool state) + { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + store.SetValue (iter, columnSelected, state); + } while (store.IterNext (ref iter)); + } + } + + private void PopulateList (IEnumerable<ISchemaContainer> containers) + { + foreach (ISchemaContainer container in containers) + store.AppendValues (true, container); + } + + private void TextDataFunc (CellLayout layout, CellRenderer cell, TreeModel model, TreeIter iter) + { + CellRendererText textRenderer = cell as CellRendererText; + ISchemaContainer schema = model.GetValue (iter, columnObj) as ISchemaContainer; + textRenderer.Text = schema.Schema.Name; + } + + private void PixbufDataFunc (CellLayout layout, CellRenderer cell, TreeModel model, TreeIter iter) + { + CellRendererPixbuf pixbufRenderer = cell as CellRendererPixbuf; + ISchemaContainer schema = model.GetValue (iter, columnObj) as ISchemaContainer; + + string iconString = null; + switch (schema.SchemaContainerType) { + case SchemaContainerType.Table: + iconString = "md-db-table"; + break; + case SchemaContainerType.View: + iconString = "md-db-view"; + break; + case SchemaContainerType.Procedure: + iconString = "md-db-procedure"; + break; + case SchemaContainerType.Query: + //TODO: iconString = Stock.Execute; + break; + } + + if (iconString != null) + pixbufRenderer.Pixbuf = MonoDevelop.Core.Gui.Services.Resources.GetIcon (iconString); + } + + private void ItemToggled (object sender, ToggledArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + bool val = (bool) store.GetValue (iter, columnSelected); + store.SetValue (iter, columnSelected, !val); + } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/SortedColumnListStore.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/SortedColumnListStore.cs new file mode 100644 index 0000000000..c91c0f50db --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/SortedColumnListStore.cs @@ -0,0 +1,227 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using Gtk; +using System; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; + +namespace MonoDevelop.Database.Components +{ + public class SortedColumnListStore + { + public event EventHandler ColumnToggled; + + protected ColumnSchemaCollection columns; + protected ListStore store; + + public const int ColSelectIndex = 0; + public const int ColNameIndex = 1; + public const int ColObjIndex = 2; + + protected bool singleCheck; + + public SortedColumnListStore (ColumnSchemaCollection columns) + { + if (columns == null) + throw new ArgumentNullException ("columns"); + + this.columns = columns; + + store = new ListStore (typeof (bool), typeof (string), typeof (ColumnSchema)); + store.SetSortColumnId (ColNameIndex, SortType.Ascending); + store.SetSortFunc (ColNameIndex, new TreeIterCompareFunc (SortName)); + + foreach (ColumnSchema col in columns) + AddColumn (col); + + columns.ItemAdded += new SortedCollectionItemEventHandler<ColumnSchema> (OnColumnAdded); + columns.ItemRemoved += new SortedCollectionItemEventHandler<ColumnSchema> (OnColumnRemoved); + } + + public ListStore Store { + get { return store; } + } + + public virtual bool SingleCheck { + get { return singleCheck; } + set { + if (value != singleCheck) { + singleCheck = value; + if (value) + DeselectAll (); + } + } + } + + public virtual ColumnSchema GetColumnSchema (TreeIter iter) + { + if (!iter.Equals (TreeIter.Zero)) + return store.GetValue (iter, ColObjIndex) as ColumnSchema; + return null; + } + + public virtual IEnumerable<ColumnSchema> CheckedColumns { + get { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + bool chk = (bool)store.GetValue (iter, ColSelectIndex); + if (chk) + yield return store.GetValue (iter, ColObjIndex) as ColumnSchema; + } while (store.IterNext (ref iter)); + } + } + } + + public virtual bool IsColumnChecked { + get { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + bool chk = (bool)store.GetValue (iter, ColSelectIndex); + if (chk) + return true; + } while (store.IterNext (ref iter)); + } + return false; + } + } + + public virtual void SelectAll () + { + SetSelectState (true); + OnColumnToggled (); + } + + public virtual void DeselectAll () + { + SetSelectState (false); + OnColumnToggled (); + } + + public virtual void Select (string name) + { + if (name == null) + throw new ArgumentNullException ("name"); + + ColumnSchema col = columns.Search (name); + if (col != null) + Select (col); + } + + public virtual void Select (ColumnSchema column) + { + if (column == null) + throw new ArgumentNullException ("column"); + + TreeIter iter = GetTreeIter (column); + if (!iter.Equals (TreeIter.Zero)) { + if (singleCheck) + SetSelectState (false); + + store.SetValue (iter, ColSelectIndex, true); + OnColumnToggled (); + } + } + + public virtual void ToggleSelect (TreeIter iter) + { + bool val = (bool) store.GetValue (iter, ColSelectIndex); + bool newVal = !val; + + if (newVal && singleCheck) + SetSelectState (false); + + store.SetValue (iter, ColSelectIndex, !val); + OnColumnToggled (); + } + + protected virtual void SetSelectState (bool state) + { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + store.SetValue (iter, ColSelectIndex, state); + } while (store.IterNext (ref iter)); + } + } + + protected virtual TreeIter GetTreeIter (ColumnSchema column) + { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + object obj = store.GetValue (iter, ColObjIndex); + + if (obj == column) + return iter; + } while (store.IterNext (ref iter)); + } + return TreeIter.Zero; + } + + protected virtual void OnColumnAdded (object sender, SortedCollectionItemEventArgs<ColumnSchema> args) + { + AddColumn (args.Item); + } + + protected virtual void AddColumn (ColumnSchema column) + { + store.AppendValues (false, column.Name, column); + + column.Changed += delegate (object sender, EventArgs args) { + TreeIter iter = GetTreeIter (sender as ColumnSchema); + if (!iter.Equals (TreeIter.Zero)) + store.SetValue (iter, ColNameIndex, column.Name); + }; + } + + protected virtual void OnColumnRemoved (object sender, SortedCollectionItemEventArgs<ColumnSchema> args) + { + TreeIter iter = GetTreeIter (args.Item); + if (!iter.Equals (TreeIter.Zero)) + store.Remove (ref iter); + } + + protected virtual int SortName (TreeModel model, TreeIter iter1, TreeIter iter2) + { + string name1 = model.GetValue (iter1, ColNameIndex) as string; + string name2 = model.GetValue (iter2, ColNameIndex) as string; + + if (name1 == null && name2 == null) return 0; + else if (name1 == null) return -1; + else if (name2 == null) return 1; + + return name1.CompareTo (name2); + } + + protected virtual void OnColumnToggled () + { + if (ColumnToggled != null) + ColumnToggled (this, EventArgs.Empty); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/SqlEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/SqlEditorWidget.cs new file mode 100644 index 0000000000..78f5423555 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/Widgets/SqlEditorWidget.cs @@ -0,0 +1,167 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+ +using Gtk; +using GtkSourceView;
+using System; +using System.IO; +using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui; +using MonoDevelop.Components; +using MonoDevelop.Components.Commands; +using MonoDevelop.Database.Sql; + +namespace MonoDevelop.Database.Components +{ + public partial class SqlEditorWidget : Bin + { + public event EventHandler TextChanged; + + private SourceView sourceView; + + public SqlEditorWidget() + { + this.Build(); + + SourceLanguagesManager lm = new SourceLanguagesManager (); + SourceLanguage lang = lm.GetLanguageFromMimeType ("text/x-sql"); + SourceBuffer buf = new SourceBuffer (lang); + buf.Highlight = true; + sourceView = new SourceView (buf); + sourceView.ShowLineNumbers = true; + + sourceView.Buffer.Changed += new EventHandler (BufferChanged); + sourceView.PopulatePopup += new PopulatePopupHandler (OnPopulatePopup); + + scrolledwindow.Add (sourceView); + ShowAll (); + } + + protected virtual void OnPopulatePopup (object sender, PopulatePopupArgs args) + { + CommandEntrySet cset = IdeApp.CommandService.CreateCommandEntrySet ("/MonoDevelop/Database/ContextMenu/SqlEditor"); + if (cset.Count > 0) { + cset.AddItem (Command.Separator); + IdeApp.CommandService.InsertOptions (args.Menu, cset, 0); + } + } + + private void BufferChanged (object sender, EventArgs args) + { + if (TextChanged != null) + TextChanged (this, EventArgs.Empty); + } + + public string Text { + get { return sourceView.Buffer.Text; } + set { + if (value == null) + sourceView.Buffer.Text = String.Empty; + else + sourceView.Buffer.Text = value; + } + } + + public bool Editable { + get { return sourceView.Editable; } + set { sourceView.Editable = value; } + } + + [CommandHandler (SqlEditorCommands.ImportFromFile)] + protected void OnImportFromFile () + { + FileChooserDialog dlg = new FileChooserDialog ( + GettextCatalog.GetString ("Import From File"), null, FileChooserAction.Open, + "gtk-cancel", ResponseType.Cancel, + "gtk-open", ResponseType.Accept + ); + dlg.SelectMultiple = false; + dlg.LocalOnly = true; + dlg.Modal = true; + + FileFilter filter = new FileFilter (); + filter.AddPattern ("*.[sS][qQ][lL]"); + filter.Name = GettextCatalog.GetString ("SQL files"); + FileFilter filterAll = new FileFilter (); + filterAll.AddPattern ("*"); + filterAll.Name = GettextCatalog.GetString ("All files"); + dlg.AddFilter (filter); + dlg.AddFilter (filterAll); + + if (dlg.Run () == (int)ResponseType.Accept) { + using (FileStream stream = File.Open (dlg.Filename, FileMode.Open)) { + using (StreamReader reader = new StreamReader (stream)) { + Text = reader.ReadToEnd (); + } + } + } + dlg.Destroy (); + } + + [CommandHandler (SqlEditorCommands.ExportToFile)] + protected void OnExportToFile () + { + FileChooserDialog dlg = new FileChooserDialog ( + GettextCatalog.GetString ("Export To File"), null, FileChooserAction.Save, + "gtk-cancel", ResponseType.Cancel, + "gtk-save", ResponseType.Accept + ); + + dlg.SelectMultiple = false; + dlg.LocalOnly = true; + dlg.Modal = true; + + FileFilter filter = new FileFilter (); + filter.AddPattern ("*.[sS][qQ][lL]"); + filter.Name = GettextCatalog.GetString ("SQL files"); + dlg.AddFilter (filter); + + if (dlg.Run () == (int)ResponseType.Accept) { + if (File.Exists (dlg.Filename)) { + bool overwrite = Services.MessageService.AskQuestion ( + GettextCatalog.GetString ("Are you sure you want to overwrite the file '{0}'?", dlg.Filename), + GettextCatalog.GetString ("Overwrite?")); + if (overwrite) { + using (FileStream stream = File.Open (dlg.Filename, FileMode.Create)) { + using (StreamWriter writer = new StreamWriter (stream)) { + writer.Write (Text); + writer.Flush (); + } + } + } + } + } + dlg.Destroy (); + } + + [CommandUpdateHandler (SqlEditorCommands.ExportToFile)] + protected void OnUpdateExportToFile (CommandInfo info) + { + info.Enabled = Text.Length > 0; + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.DataGrid.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.DataGrid.cs new file mode 100644 index 0000000000..b81d352d26 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.DataGrid.cs @@ -0,0 +1,166 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Components { + + + public partial class DataGrid { + + private Gtk.VBox vbox; + + private Gtk.ScrolledWindow scrolledwindow; + + private Gtk.TreeView grid; + + private Gtk.HBox hbox; + + private Gtk.Button buttonFirst; + + private Gtk.Button buttonPrevious; + + private Gtk.Entry entryCurrent; + + private Gtk.Label label1; + + private Gtk.Entry entryTotal; + + private Gtk.Button buttonNext; + + private Gtk.Button buttonLast; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Components.DataGrid + Stetic.BinContainer.Attach(this); + this.Name = "MonoDevelop.Database.Components.DataGrid"; + // Container child MonoDevelop.Database.Components.DataGrid.Gtk.Container+ContainerChild + this.vbox = new Gtk.VBox(); + this.vbox.Name = "vbox"; + this.vbox.Spacing = 5; + this.vbox.BorderWidth = ((uint)(5)); + // Container child vbox.Gtk.Box+BoxChild + this.scrolledwindow = new Gtk.ScrolledWindow(); + this.scrolledwindow.CanFocus = true; + this.scrolledwindow.Name = "scrolledwindow"; + this.scrolledwindow.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindow.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindow.ShadowType = ((Gtk.ShadowType)(1)); + // Container child scrolledwindow.Gtk.Container+ContainerChild + this.grid = new Gtk.TreeView(); + this.grid.CanDefault = true; + this.grid.CanFocus = true; + this.grid.Name = "grid"; + this.grid.EnableSearch = false; + this.grid.HeadersClickable = true; + this.scrolledwindow.Add(this.grid); + this.vbox.Add(this.scrolledwindow); + Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.vbox[this.scrolledwindow])); + w2.Position = 0; + // Container child vbox.Gtk.Box+BoxChild + this.hbox = new Gtk.HBox(); + this.hbox.Name = "hbox"; + this.hbox.Spacing = 5; + // Container child hbox.Gtk.Box+BoxChild + this.buttonFirst = new Gtk.Button(); + this.buttonFirst.CanFocus = true; + this.buttonFirst.Name = "buttonFirst"; + this.buttonFirst.UseStock = true; + this.buttonFirst.UseUnderline = true; + this.buttonFirst.Label = "gtk-goto-first"; + this.hbox.Add(this.buttonFirst); + Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.hbox[this.buttonFirst])); + w3.Position = 0; + w3.Expand = false; + w3.Fill = false; + // Container child hbox.Gtk.Box+BoxChild + this.buttonPrevious = new Gtk.Button(); + this.buttonPrevious.CanFocus = true; + this.buttonPrevious.Name = "buttonPrevious"; + this.buttonPrevious.UseStock = true; + this.buttonPrevious.UseUnderline = true; + this.buttonPrevious.Label = "gtk-go-back"; + this.hbox.Add(this.buttonPrevious); + Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.hbox[this.buttonPrevious])); + w4.Position = 1; + w4.Expand = false; + w4.Fill = false; + // Container child hbox.Gtk.Box+BoxChild + this.entryCurrent = new Gtk.Entry(); + this.entryCurrent.CanFocus = true; + this.entryCurrent.Name = "entryCurrent"; + this.entryCurrent.IsEditable = true; + this.entryCurrent.InvisibleChar = '●'; + this.entryCurrent.Xalign = 0.5F; + this.hbox.Add(this.entryCurrent); + Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(this.hbox[this.entryCurrent])); + w5.Position = 2; + w5.Expand = false; + // Container child hbox.Gtk.Box+BoxChild + this.label1 = new Gtk.Label(); + this.label1.Name = "label1"; + this.label1.LabelProp = Mono.Unix.Catalog.GetString("of"); + this.hbox.Add(this.label1); + Gtk.Box.BoxChild w6 = ((Gtk.Box.BoxChild)(this.hbox[this.label1])); + w6.Position = 3; + w6.Expand = false; + w6.Fill = false; + // Container child hbox.Gtk.Box+BoxChild + this.entryTotal = new Gtk.Entry(); + this.entryTotal.CanFocus = true; + this.entryTotal.Name = "entryTotal"; + this.entryTotal.IsEditable = false; + this.entryTotal.InvisibleChar = '●'; + this.entryTotal.Xalign = 0.5F; + this.hbox.Add(this.entryTotal); + Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(this.hbox[this.entryTotal])); + w7.Position = 4; + w7.Expand = false; + // Container child hbox.Gtk.Box+BoxChild + this.buttonNext = new Gtk.Button(); + this.buttonNext.CanFocus = true; + this.buttonNext.Name = "buttonNext"; + this.buttonNext.UseStock = true; + this.buttonNext.UseUnderline = true; + this.buttonNext.Label = "gtk-go-forward"; + this.hbox.Add(this.buttonNext); + Gtk.Box.BoxChild w8 = ((Gtk.Box.BoxChild)(this.hbox[this.buttonNext])); + w8.Position = 5; + w8.Expand = false; + w8.Fill = false; + // Container child hbox.Gtk.Box+BoxChild + this.buttonLast = new Gtk.Button(); + this.buttonLast.CanFocus = true; + this.buttonLast.Name = "buttonLast"; + this.buttonLast.UseStock = true; + this.buttonLast.UseUnderline = true; + this.buttonLast.Label = "gtk-goto-last"; + this.hbox.Add(this.buttonLast); + Gtk.Box.BoxChild w9 = ((Gtk.Box.BoxChild)(this.hbox[this.buttonLast])); + w9.Position = 6; + w9.Expand = false; + w9.Fill = false; + this.vbox.Add(this.hbox); + Gtk.Box.BoxChild w10 = ((Gtk.Box.BoxChild)(this.vbox[this.hbox])); + w10.Position = 1; + w10.Expand = false; + w10.Fill = false; + this.Add(this.vbox); + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.Show(); + this.buttonFirst.Clicked += new System.EventHandler(this.ButtonFirstClicked); + this.buttonPrevious.Clicked += new System.EventHandler(this.ButtonPreviousClicked); + this.entryCurrent.Activated += new System.EventHandler(this.EntryCurrentActivated); + this.buttonNext.Clicked += new System.EventHandler(this.ButtonNextClicked); + this.buttonLast.Clicked += new System.EventHandler(this.ButtonLastClicked); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.DatabaseConnectionSettingsDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.DatabaseConnectionSettingsDialog.cs new file mode 100644 index 0000000000..a55a423d1b --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.DatabaseConnectionSettingsDialog.cs @@ -0,0 +1,487 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Components { + + + public partial class DatabaseConnectionSettingsDialog { + + private Gtk.Notebook notebook; + + private Gtk.Table tableGeneral; + + private Gtk.ComboBox comboProvider; + + private Gtk.Entry entryName; + + private Gtk.Entry entryServer; + + private Gtk.Entry entryUsername; + + private Gtk.HBox hboxDatabase; + + private Gtk.ComboBoxEntry comboDatabase; + + private Gtk.Button buttonRefresh; + + private Gtk.Button buttonOpen; + + private Gtk.HBox hboxPassword; + + private Gtk.Entry entryPassword; + + private Gtk.CheckButton checkSavePassword; + + private Gtk.Label label3; + + private Gtk.Label label4; + + private Gtk.Label label5; + + private Gtk.Label label6; + + private Gtk.Label label7; + + private Gtk.Label label8; + + private Gtk.Label label9; + + private Gtk.SpinButton spinPort; + + private Gtk.Label label1; + + private Gtk.Table tableAdvanced; + + private Gtk.CheckButton checkCustom; + + private Gtk.Label label10; + + private Gtk.Label label11; + + private Gtk.ScrolledWindow scrolledwindow; + + private Gtk.TextView textConnectionString; + + private Gtk.SpinButton spinMaxPoolSize; + + private Gtk.SpinButton spinMinPoolSize; + + private Gtk.Label label2; + + private Gtk.Button buttonCancel; + + private Gtk.Button buttonOk; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Components.DatabaseConnectionSettingsDialog + this.Name = "MonoDevelop.Database.Components.DatabaseConnectionSettingsDialog"; + this.TypeHint = ((Gdk.WindowTypeHint)(1)); + this.WindowPosition = ((Gtk.WindowPosition)(1)); + this.SkipTaskbarHint = true; + this.HasSeparator = false; + // Internal child MonoDevelop.Database.Components.DatabaseConnectionSettingsDialog.VBox + Gtk.VBox w1 = this.VBox; + w1.Name = "dialog1_VBox"; + w1.BorderWidth = ((uint)(2)); + // Container child dialog1_VBox.Gtk.Box+BoxChild + this.notebook = new Gtk.Notebook(); + this.notebook.CanFocus = true; + this.notebook.Name = "notebook"; + this.notebook.CurrentPage = 0; + // Container child notebook.Gtk.Notebook+NotebookChild + this.tableGeneral = new Gtk.Table(((uint)(7)), ((uint)(2)), false); + this.tableGeneral.Name = "tableGeneral"; + this.tableGeneral.RowSpacing = ((uint)(6)); + this.tableGeneral.ColumnSpacing = ((uint)(6)); + this.tableGeneral.BorderWidth = ((uint)(6)); + // Container child tableGeneral.Gtk.Table+TableChild + this.comboProvider = new Gtk.ComboBox(); + this.comboProvider.Name = "comboProvider"; + this.tableGeneral.Add(this.comboProvider); + Gtk.Table.TableChild w2 = ((Gtk.Table.TableChild)(this.tableGeneral[this.comboProvider])); + w2.LeftAttach = ((uint)(1)); + w2.RightAttach = ((uint)(2)); + w2.XOptions = ((Gtk.AttachOptions)(4)); + w2.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableGeneral.Gtk.Table+TableChild + this.entryName = new Gtk.Entry(); + this.entryName.CanDefault = true; + this.entryName.CanFocus = true; + this.entryName.Name = "entryName"; + this.entryName.IsEditable = true; + this.entryName.ActivatesDefault = true; + this.entryName.InvisibleChar = '●'; + this.tableGeneral.Add(this.entryName); + Gtk.Table.TableChild w3 = ((Gtk.Table.TableChild)(this.tableGeneral[this.entryName])); + w3.TopAttach = ((uint)(1)); + w3.BottomAttach = ((uint)(2)); + w3.LeftAttach = ((uint)(1)); + w3.RightAttach = ((uint)(2)); + w3.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableGeneral.Gtk.Table+TableChild + this.entryServer = new Gtk.Entry(); + this.entryServer.CanFocus = true; + this.entryServer.Name = "entryServer"; + this.entryServer.IsEditable = true; + this.entryServer.InvisibleChar = '●'; + this.tableGeneral.Add(this.entryServer); + Gtk.Table.TableChild w4 = ((Gtk.Table.TableChild)(this.tableGeneral[this.entryServer])); + w4.TopAttach = ((uint)(2)); + w4.BottomAttach = ((uint)(3)); + w4.LeftAttach = ((uint)(1)); + w4.RightAttach = ((uint)(2)); + w4.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableGeneral.Gtk.Table+TableChild + this.entryUsername = new Gtk.Entry(); + this.entryUsername.CanFocus = true; + this.entryUsername.Name = "entryUsername"; + this.entryUsername.IsEditable = true; + this.entryUsername.InvisibleChar = '●'; + this.tableGeneral.Add(this.entryUsername); + Gtk.Table.TableChild w5 = ((Gtk.Table.TableChild)(this.tableGeneral[this.entryUsername])); + w5.TopAttach = ((uint)(4)); + w5.BottomAttach = ((uint)(5)); + w5.LeftAttach = ((uint)(1)); + w5.RightAttach = ((uint)(2)); + w5.XOptions = ((Gtk.AttachOptions)(4)); + w5.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableGeneral.Gtk.Table+TableChild + this.hboxDatabase = new Gtk.HBox(); + this.hboxDatabase.Name = "hboxDatabase"; + this.hboxDatabase.Spacing = 6; + // Container child hboxDatabase.Gtk.Box+BoxChild + this.comboDatabase = Gtk.ComboBoxEntry.NewText(); + this.comboDatabase.Name = "comboDatabase"; + this.hboxDatabase.Add(this.comboDatabase); + Gtk.Box.BoxChild w6 = ((Gtk.Box.BoxChild)(this.hboxDatabase[this.comboDatabase])); + w6.Position = 0; + // Container child hboxDatabase.Gtk.Box+BoxChild + this.buttonRefresh = new Gtk.Button(); + this.buttonRefresh.CanFocus = true; + this.buttonRefresh.Name = "buttonRefresh"; + this.buttonRefresh.UseStock = true; + this.buttonRefresh.UseUnderline = true; + this.buttonRefresh.Label = "gtk-refresh"; + this.hboxDatabase.Add(this.buttonRefresh); + Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(this.hboxDatabase[this.buttonRefresh])); + w7.Position = 1; + w7.Expand = false; + w7.Fill = false; + // Container child hboxDatabase.Gtk.Box+BoxChild + this.buttonOpen = new Gtk.Button(); + this.buttonOpen.CanFocus = true; + this.buttonOpen.Name = "buttonOpen"; + this.buttonOpen.UseStock = true; + this.buttonOpen.UseUnderline = true; + this.buttonOpen.Label = "gtk-open"; + this.hboxDatabase.Add(this.buttonOpen); + Gtk.Box.BoxChild w8 = ((Gtk.Box.BoxChild)(this.hboxDatabase[this.buttonOpen])); + w8.Position = 2; + w8.Expand = false; + w8.Fill = false; + this.tableGeneral.Add(this.hboxDatabase); + Gtk.Table.TableChild w9 = ((Gtk.Table.TableChild)(this.tableGeneral[this.hboxDatabase])); + w9.TopAttach = ((uint)(6)); + w9.BottomAttach = ((uint)(7)); + w9.LeftAttach = ((uint)(1)); + w9.RightAttach = ((uint)(2)); + w9.XOptions = ((Gtk.AttachOptions)(4)); + w9.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableGeneral.Gtk.Table+TableChild + this.hboxPassword = new Gtk.HBox(); + this.hboxPassword.Name = "hboxPassword"; + this.hboxPassword.Spacing = 6; + // Container child hboxPassword.Gtk.Box+BoxChild + this.entryPassword = new Gtk.Entry(); + this.entryPassword.CanFocus = true; + this.entryPassword.Name = "entryPassword"; + this.entryPassword.IsEditable = true; + this.entryPassword.Visibility = false; + this.entryPassword.InvisibleChar = '●'; + this.hboxPassword.Add(this.entryPassword); + Gtk.Box.BoxChild w10 = ((Gtk.Box.BoxChild)(this.hboxPassword[this.entryPassword])); + w10.Position = 0; + // Container child hboxPassword.Gtk.Box+BoxChild + this.checkSavePassword = new Gtk.CheckButton(); + this.checkSavePassword.CanFocus = true; + this.checkSavePassword.Name = "checkSavePassword"; + this.checkSavePassword.Label = Mono.Unix.Catalog.GetString("Save Password"); + this.checkSavePassword.Active = true; + this.checkSavePassword.DrawIndicator = true; + this.checkSavePassword.UseUnderline = true; + this.hboxPassword.Add(this.checkSavePassword); + Gtk.Box.BoxChild w11 = ((Gtk.Box.BoxChild)(this.hboxPassword[this.checkSavePassword])); + w11.Position = 1; + w11.Expand = false; + this.tableGeneral.Add(this.hboxPassword); + Gtk.Table.TableChild w12 = ((Gtk.Table.TableChild)(this.tableGeneral[this.hboxPassword])); + w12.TopAttach = ((uint)(5)); + w12.BottomAttach = ((uint)(6)); + w12.LeftAttach = ((uint)(1)); + w12.RightAttach = ((uint)(2)); + w12.XOptions = ((Gtk.AttachOptions)(4)); + w12.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableGeneral.Gtk.Table+TableChild + this.label3 = new Gtk.Label(); + this.label3.Name = "label3"; + this.label3.Xalign = 0F; + this.label3.LabelProp = Mono.Unix.Catalog.GetString("Type"); + this.tableGeneral.Add(this.label3); + Gtk.Table.TableChild w13 = ((Gtk.Table.TableChild)(this.tableGeneral[this.label3])); + w13.XOptions = ((Gtk.AttachOptions)(4)); + w13.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableGeneral.Gtk.Table+TableChild + this.label4 = new Gtk.Label(); + this.label4.Name = "label4"; + this.label4.Xalign = 0F; + this.label4.LabelProp = Mono.Unix.Catalog.GetString("Name"); + this.tableGeneral.Add(this.label4); + Gtk.Table.TableChild w14 = ((Gtk.Table.TableChild)(this.tableGeneral[this.label4])); + w14.TopAttach = ((uint)(1)); + w14.BottomAttach = ((uint)(2)); + w14.XOptions = ((Gtk.AttachOptions)(4)); + w14.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableGeneral.Gtk.Table+TableChild + this.label5 = new Gtk.Label(); + this.label5.Name = "label5"; + this.label5.Xalign = 0F; + this.label5.LabelProp = Mono.Unix.Catalog.GetString("Server"); + this.tableGeneral.Add(this.label5); + Gtk.Table.TableChild w15 = ((Gtk.Table.TableChild)(this.tableGeneral[this.label5])); + w15.TopAttach = ((uint)(2)); + w15.BottomAttach = ((uint)(3)); + w15.XOptions = ((Gtk.AttachOptions)(4)); + w15.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableGeneral.Gtk.Table+TableChild + this.label6 = new Gtk.Label(); + this.label6.Name = "label6"; + this.label6.Xalign = 0F; + this.label6.LabelProp = Mono.Unix.Catalog.GetString("Port"); + this.tableGeneral.Add(this.label6); + Gtk.Table.TableChild w16 = ((Gtk.Table.TableChild)(this.tableGeneral[this.label6])); + w16.TopAttach = ((uint)(3)); + w16.BottomAttach = ((uint)(4)); + w16.XOptions = ((Gtk.AttachOptions)(4)); + w16.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableGeneral.Gtk.Table+TableChild + this.label7 = new Gtk.Label(); + this.label7.Name = "label7"; + this.label7.Xalign = 0F; + this.label7.LabelProp = Mono.Unix.Catalog.GetString("Username"); + this.tableGeneral.Add(this.label7); + Gtk.Table.TableChild w17 = ((Gtk.Table.TableChild)(this.tableGeneral[this.label7])); + w17.TopAttach = ((uint)(4)); + w17.BottomAttach = ((uint)(5)); + w17.XOptions = ((Gtk.AttachOptions)(4)); + w17.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableGeneral.Gtk.Table+TableChild + this.label8 = new Gtk.Label(); + this.label8.Name = "label8"; + this.label8.Xalign = 0F; + this.label8.LabelProp = Mono.Unix.Catalog.GetString("Password"); + this.tableGeneral.Add(this.label8); + Gtk.Table.TableChild w18 = ((Gtk.Table.TableChild)(this.tableGeneral[this.label8])); + w18.TopAttach = ((uint)(5)); + w18.BottomAttach = ((uint)(6)); + w18.XOptions = ((Gtk.AttachOptions)(4)); + w18.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableGeneral.Gtk.Table+TableChild + this.label9 = new Gtk.Label(); + this.label9.Name = "label9"; + this.label9.Xalign = 0F; + this.label9.LabelProp = Mono.Unix.Catalog.GetString("Database"); + this.tableGeneral.Add(this.label9); + Gtk.Table.TableChild w19 = ((Gtk.Table.TableChild)(this.tableGeneral[this.label9])); + w19.TopAttach = ((uint)(6)); + w19.BottomAttach = ((uint)(7)); + w19.XOptions = ((Gtk.AttachOptions)(4)); + w19.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableGeneral.Gtk.Table+TableChild + this.spinPort = new Gtk.SpinButton(1, 65535, 1); + this.spinPort.CanFocus = true; + this.spinPort.Name = "spinPort"; + this.spinPort.Adjustment.PageIncrement = 10; + this.spinPort.ClimbRate = 1; + this.spinPort.Numeric = true; + this.spinPort.Value = 1; + this.tableGeneral.Add(this.spinPort); + Gtk.Table.TableChild w20 = ((Gtk.Table.TableChild)(this.tableGeneral[this.spinPort])); + w20.TopAttach = ((uint)(3)); + w20.BottomAttach = ((uint)(4)); + w20.LeftAttach = ((uint)(1)); + w20.RightAttach = ((uint)(2)); + w20.XOptions = ((Gtk.AttachOptions)(4)); + w20.YOptions = ((Gtk.AttachOptions)(4)); + this.notebook.Add(this.tableGeneral); + Gtk.Notebook.NotebookChild w21 = ((Gtk.Notebook.NotebookChild)(this.notebook[this.tableGeneral])); + w21.TabExpand = false; + // Notebook tab + this.label1 = new Gtk.Label(); + this.label1.Name = "label1"; + this.label1.LabelProp = Mono.Unix.Catalog.GetString("General"); + this.notebook.SetTabLabel(this.tableGeneral, this.label1); + this.label1.ShowAll(); + // Container child notebook.Gtk.Notebook+NotebookChild + this.tableAdvanced = new Gtk.Table(((uint)(4)), ((uint)(2)), false); + this.tableAdvanced.Name = "tableAdvanced"; + this.tableAdvanced.RowSpacing = ((uint)(6)); + this.tableAdvanced.ColumnSpacing = ((uint)(6)); + this.tableAdvanced.BorderWidth = ((uint)(6)); + // Container child tableAdvanced.Gtk.Table+TableChild + this.checkCustom = new Gtk.CheckButton(); + this.checkCustom.CanFocus = true; + this.checkCustom.Name = "checkCustom"; + this.checkCustom.Label = Mono.Unix.Catalog.GetString("Use custom connection string"); + this.checkCustom.DrawIndicator = true; + this.checkCustom.UseUnderline = true; + this.tableAdvanced.Add(this.checkCustom); + Gtk.Table.TableChild w22 = ((Gtk.Table.TableChild)(this.tableAdvanced[this.checkCustom])); + w22.TopAttach = ((uint)(2)); + w22.BottomAttach = ((uint)(3)); + w22.RightAttach = ((uint)(2)); + w22.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableAdvanced.Gtk.Table+TableChild + this.label10 = new Gtk.Label(); + this.label10.Name = "label10"; + this.label10.Xalign = 0F; + this.label10.LabelProp = Mono.Unix.Catalog.GetString("Min Pool Size"); + this.tableAdvanced.Add(this.label10); + Gtk.Table.TableChild w23 = ((Gtk.Table.TableChild)(this.tableAdvanced[this.label10])); + w23.XOptions = ((Gtk.AttachOptions)(4)); + w23.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableAdvanced.Gtk.Table+TableChild + this.label11 = new Gtk.Label(); + this.label11.Name = "label11"; + this.label11.Xalign = 0F; + this.label11.LabelProp = Mono.Unix.Catalog.GetString("Max Pool Size"); + this.tableAdvanced.Add(this.label11); + Gtk.Table.TableChild w24 = ((Gtk.Table.TableChild)(this.tableAdvanced[this.label11])); + w24.TopAttach = ((uint)(1)); + w24.BottomAttach = ((uint)(2)); + w24.XOptions = ((Gtk.AttachOptions)(4)); + w24.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableAdvanced.Gtk.Table+TableChild + this.scrolledwindow = new Gtk.ScrolledWindow(); + this.scrolledwindow.Sensitive = false; + this.scrolledwindow.CanFocus = true; + this.scrolledwindow.Name = "scrolledwindow"; + this.scrolledwindow.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindow.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindow.ShadowType = ((Gtk.ShadowType)(1)); + // Container child scrolledwindow.Gtk.Container+ContainerChild + this.textConnectionString = new Gtk.TextView(); + this.textConnectionString.CanFocus = true; + this.textConnectionString.Name = "textConnectionString"; + this.scrolledwindow.Add(this.textConnectionString); + this.tableAdvanced.Add(this.scrolledwindow); + Gtk.Table.TableChild w26 = ((Gtk.Table.TableChild)(this.tableAdvanced[this.scrolledwindow])); + w26.TopAttach = ((uint)(3)); + w26.BottomAttach = ((uint)(4)); + w26.RightAttach = ((uint)(2)); + w26.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableAdvanced.Gtk.Table+TableChild + this.spinMaxPoolSize = new Gtk.SpinButton(1, 100, 1); + this.spinMaxPoolSize.CanFocus = true; + this.spinMaxPoolSize.Name = "spinMaxPoolSize"; + this.spinMaxPoolSize.Adjustment.PageIncrement = 10; + this.spinMaxPoolSize.ClimbRate = 1; + this.spinMaxPoolSize.Numeric = true; + this.spinMaxPoolSize.Value = 5; + this.tableAdvanced.Add(this.spinMaxPoolSize); + Gtk.Table.TableChild w27 = ((Gtk.Table.TableChild)(this.tableAdvanced[this.spinMaxPoolSize])); + w27.TopAttach = ((uint)(1)); + w27.BottomAttach = ((uint)(2)); + w27.LeftAttach = ((uint)(1)); + w27.RightAttach = ((uint)(2)); + w27.XOptions = ((Gtk.AttachOptions)(4)); + w27.YOptions = ((Gtk.AttachOptions)(4)); + // Container child tableAdvanced.Gtk.Table+TableChild + this.spinMinPoolSize = new Gtk.SpinButton(1, 100, 1); + this.spinMinPoolSize.CanFocus = true; + this.spinMinPoolSize.Name = "spinMinPoolSize"; + this.spinMinPoolSize.Adjustment.PageIncrement = 10; + this.spinMinPoolSize.ClimbRate = 1; + this.spinMinPoolSize.Numeric = true; + this.spinMinPoolSize.Value = 1; + this.tableAdvanced.Add(this.spinMinPoolSize); + Gtk.Table.TableChild w28 = ((Gtk.Table.TableChild)(this.tableAdvanced[this.spinMinPoolSize])); + w28.LeftAttach = ((uint)(1)); + w28.RightAttach = ((uint)(2)); + w28.XOptions = ((Gtk.AttachOptions)(4)); + w28.YOptions = ((Gtk.AttachOptions)(4)); + this.notebook.Add(this.tableAdvanced); + Gtk.Notebook.NotebookChild w29 = ((Gtk.Notebook.NotebookChild)(this.notebook[this.tableAdvanced])); + w29.Position = 1; + w29.TabExpand = false; + // Notebook tab + this.label2 = new Gtk.Label(); + this.label2.Name = "label2"; + this.label2.LabelProp = Mono.Unix.Catalog.GetString("Advanced"); + this.notebook.SetTabLabel(this.tableAdvanced, this.label2); + this.label2.ShowAll(); + w1.Add(this.notebook); + Gtk.Box.BoxChild w30 = ((Gtk.Box.BoxChild)(w1[this.notebook])); + w30.Position = 0; + w30.Expand = false; + w30.Fill = false; + // Internal child MonoDevelop.Database.Components.DatabaseConnectionSettingsDialog.ActionArea + Gtk.HButtonBox w31 = this.ActionArea; + w31.Name = "dialog1_ActionArea"; + w31.Spacing = 6; + w31.BorderWidth = ((uint)(5)); + w31.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonCancel = new Gtk.Button(); + this.buttonCancel.CanDefault = true; + this.buttonCancel.CanFocus = true; + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.UseStock = true; + this.buttonCancel.UseUnderline = true; + this.buttonCancel.Label = "gtk-cancel"; + this.AddActionWidget(this.buttonCancel, -6); + Gtk.ButtonBox.ButtonBoxChild w32 = ((Gtk.ButtonBox.ButtonBoxChild)(w31[this.buttonCancel])); + w32.Expand = false; + w32.Fill = false; + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonOk = new Gtk.Button(); + this.buttonOk.CanDefault = true; + this.buttonOk.CanFocus = true; + this.buttonOk.Name = "buttonOk"; + this.buttonOk.UseStock = true; + this.buttonOk.UseUnderline = true; + this.buttonOk.Label = "gtk-ok"; + this.AddActionWidget(this.buttonOk, -5); + Gtk.ButtonBox.ButtonBoxChild w33 = ((Gtk.ButtonBox.ButtonBoxChild)(w31[this.buttonOk])); + w33.Position = 1; + w33.Expand = false; + w33.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.DefaultWidth = 606; + this.DefaultHeight = 351; + this.entryName.HasDefault = true; + this.Show(); + this.spinPort.Changed += new System.EventHandler(this.PortChanged); + this.entryPassword.Changed += new System.EventHandler(this.PasswordChanged); + this.buttonRefresh.Clicked += new System.EventHandler(this.RefreshClicked); + this.buttonOpen.Clicked += new System.EventHandler(this.OpenClicked); + this.entryUsername.Changed += new System.EventHandler(this.UsernameChanged); + this.entryServer.Changed += new System.EventHandler(this.ServerChanged); + this.entryName.Changed += new System.EventHandler(this.NameChanged); + this.comboProvider.Changed += new System.EventHandler(this.ProviderChanged); + this.spinMinPoolSize.Changed += new System.EventHandler(this.MinPoolSizeChanged); + this.spinMaxPoolSize.Changed += new System.EventHandler(this.MaxPoolSizeChanged); + this.buttonCancel.Clicked += new System.EventHandler(this.OnCancelClicked); + this.buttonOk.Clicked += new System.EventHandler(this.OnOkClicked); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.SelectColumnDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.SelectColumnDialog.cs new file mode 100644 index 0000000000..49c9cab9a9 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.SelectColumnDialog.cs @@ -0,0 +1,123 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Components { + + + public partial class SelectColumnDialog { + + private Gtk.HBox hboxContent; + + private Gtk.VButtonBox vbuttonbox1; + + private Gtk.Button buttonSelectAll; + + private Gtk.Button buttonDeselectAll; + + private Gtk.Button buttonCancel; + + private Gtk.Button buttonOk; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Components.SelectColumnDialog + this.Name = "MonoDevelop.Database.Components.SelectColumnDialog"; + this.Title = Mono.Unix.Catalog.GetString("Select Column"); + this.TypeHint = ((Gdk.WindowTypeHint)(1)); + this.WindowPosition = ((Gtk.WindowPosition)(1)); + this.DestroyWithParent = true; + this.SkipTaskbarHint = true; + this.HasSeparator = false; + // Internal child MonoDevelop.Database.Components.SelectColumnDialog.VBox + Gtk.VBox w1 = this.VBox; + w1.Name = "Dialog_Vbox"; + w1.BorderWidth = ((uint)(2)); + // Container child Dialog_Vbox.Gtk.Box+BoxChild + this.hboxContent = new Gtk.HBox(); + this.hboxContent.Name = "hboxContent"; + this.hboxContent.Spacing = 6; + // Container child hboxContent.Gtk.Box+BoxChild + this.vbuttonbox1 = new Gtk.VButtonBox(); + this.vbuttonbox1.Name = "vbuttonbox1"; + this.vbuttonbox1.Spacing = 6; + this.vbuttonbox1.LayoutStyle = ((Gtk.ButtonBoxStyle)(3)); + // Container child vbuttonbox1.Gtk.ButtonBox+ButtonBoxChild + this.buttonSelectAll = new Gtk.Button(); + this.buttonSelectAll.CanFocus = true; + this.buttonSelectAll.Name = "buttonSelectAll"; + this.buttonSelectAll.UseUnderline = true; + this.buttonSelectAll.Label = Mono.Unix.Catalog.GetString("Select All"); + this.vbuttonbox1.Add(this.buttonSelectAll); + Gtk.ButtonBox.ButtonBoxChild w2 = ((Gtk.ButtonBox.ButtonBoxChild)(this.vbuttonbox1[this.buttonSelectAll])); + w2.Expand = false; + w2.Fill = false; + // Container child vbuttonbox1.Gtk.ButtonBox+ButtonBoxChild + this.buttonDeselectAll = new Gtk.Button(); + this.buttonDeselectAll.CanFocus = true; + this.buttonDeselectAll.Name = "buttonDeselectAll"; + this.buttonDeselectAll.UseUnderline = true; + this.buttonDeselectAll.Label = Mono.Unix.Catalog.GetString("Deselect All"); + this.vbuttonbox1.Add(this.buttonDeselectAll); + Gtk.ButtonBox.ButtonBoxChild w3 = ((Gtk.ButtonBox.ButtonBoxChild)(this.vbuttonbox1[this.buttonDeselectAll])); + w3.Position = 1; + w3.Expand = false; + w3.Fill = false; + this.hboxContent.Add(this.vbuttonbox1); + Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.hboxContent[this.vbuttonbox1])); + w4.PackType = ((Gtk.PackType)(1)); + w4.Position = 1; + w4.Expand = false; + w4.Fill = false; + w1.Add(this.hboxContent); + Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(w1[this.hboxContent])); + w5.Position = 0; + // Internal child MonoDevelop.Database.Components.SelectColumnDialog.ActionArea + Gtk.HButtonBox w6 = this.ActionArea; + w6.Name = "GtkDialog_ActionArea"; + w6.Spacing = 6; + w6.BorderWidth = ((uint)(5)); + w6.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); + // Container child GtkDialog_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonCancel = new Gtk.Button(); + this.buttonCancel.CanDefault = true; + this.buttonCancel.CanFocus = true; + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.UseStock = true; + this.buttonCancel.UseUnderline = true; + this.buttonCancel.Label = "gtk-cancel"; + this.AddActionWidget(this.buttonCancel, -6); + Gtk.ButtonBox.ButtonBoxChild w7 = ((Gtk.ButtonBox.ButtonBoxChild)(w6[this.buttonCancel])); + w7.Expand = false; + w7.Fill = false; + // Container child GtkDialog_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonOk = new Gtk.Button(); + this.buttonOk.Sensitive = false; + this.buttonOk.CanDefault = true; + this.buttonOk.CanFocus = true; + this.buttonOk.Name = "buttonOk"; + this.buttonOk.UseStock = true; + this.buttonOk.UseUnderline = true; + this.buttonOk.Label = "gtk-ok"; + this.AddActionWidget(this.buttonOk, -5); + Gtk.ButtonBox.ButtonBoxChild w8 = ((Gtk.ButtonBox.ButtonBoxChild)(w6[this.buttonOk])); + w8.Position = 1; + w8.Expand = false; + w8.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.DefaultWidth = 400; + this.DefaultHeight = 300; + this.Show(); + this.buttonSelectAll.Clicked += new System.EventHandler(this.SelectAllClicked); + this.buttonDeselectAll.Clicked += new System.EventHandler(this.DeselectAllClicked); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.ShowImageDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.ShowImageDialog.cs new file mode 100644 index 0000000000..f9f61b347b --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.ShowImageDialog.cs @@ -0,0 +1,113 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Components { + + + public partial class ShowImageDialog { + + private Gtk.ScrolledWindow scrolledwindow; + + private Gtk.Image image1; + + private Gtk.HBox hboxError; + + private Gtk.Image image; + + private Gtk.Label label; + + private Gtk.Button buttonClose; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Components.ShowImageDialog + this.Name = "MonoDevelop.Database.Components.ShowImageDialog"; + this.Title = Mono.Unix.Catalog.GetString("Image"); + this.TypeHint = ((Gdk.WindowTypeHint)(1)); + this.WindowPosition = ((Gtk.WindowPosition)(1)); + this.SkipTaskbarHint = true; + this.HasSeparator = false; + // Internal child MonoDevelop.Database.Components.ShowImageDialog.VBox + Gtk.VBox w1 = this.VBox; + w1.Name = "dialog1_VBox"; + w1.BorderWidth = ((uint)(2)); + // Container child dialog1_VBox.Gtk.Box+BoxChild + this.scrolledwindow = new Gtk.ScrolledWindow(); + this.scrolledwindow.CanFocus = true; + this.scrolledwindow.Name = "scrolledwindow"; + this.scrolledwindow.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindow.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindow.ShadowType = ((Gtk.ShadowType)(1)); + // Container child scrolledwindow.Gtk.Container+ContainerChild + Gtk.Viewport w2 = new Gtk.Viewport(); + w2.ShadowType = ((Gtk.ShadowType)(0)); + // Container child GtkViewport.Gtk.Container+ContainerChild + this.image1 = new Gtk.Image(); + this.image1.Name = "image1"; + w2.Add(this.image1); + this.scrolledwindow.Add(w2); + w1.Add(this.scrolledwindow); + Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(w1[this.scrolledwindow])); + w5.Position = 0; + // Container child dialog1_VBox.Gtk.Box+BoxChild + this.hboxError = new Gtk.HBox(); + this.hboxError.Name = "hboxError"; + this.hboxError.Spacing = 6; + // Container child hboxError.Gtk.Box+BoxChild + this.image = new Gtk.Image(); + this.image.Name = "image"; + this.image.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-dialog-error", Gtk.IconSize.Menu, 16); + this.hboxError.Add(this.image); + Gtk.Box.BoxChild w6 = ((Gtk.Box.BoxChild)(this.hboxError[this.image])); + w6.Position = 0; + w6.Expand = false; + w6.Fill = false; + // Container child hboxError.Gtk.Box+BoxChild + this.label = new Gtk.Label(); + this.label.Name = "label"; + this.label.Xalign = 0F; + this.label.LabelProp = Mono.Unix.Catalog.GetString("Unable to load object as Image"); + this.hboxError.Add(this.label); + Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(this.hboxError[this.label])); + w7.Position = 1; + w1.Add(this.hboxError); + Gtk.Box.BoxChild w8 = ((Gtk.Box.BoxChild)(w1[this.hboxError])); + w8.Position = 1; + w8.Expand = false; + w8.Fill = false; + // Internal child MonoDevelop.Database.Components.ShowImageDialog.ActionArea + Gtk.HButtonBox w9 = this.ActionArea; + w9.Name = "dialog1_ActionArea"; + w9.Spacing = 6; + w9.BorderWidth = ((uint)(5)); + w9.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonClose = new Gtk.Button(); + this.buttonClose.CanDefault = true; + this.buttonClose.CanFocus = true; + this.buttonClose.Name = "buttonClose"; + this.buttonClose.UseStock = true; + this.buttonClose.UseUnderline = true; + this.buttonClose.Label = "gtk-close"; + this.AddActionWidget(this.buttonClose, -7); + Gtk.ButtonBox.ButtonBoxChild w10 = ((Gtk.ButtonBox.ButtonBoxChild)(w9[this.buttonClose])); + w10.Expand = false; + w10.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.DefaultWidth = 400; + this.DefaultHeight = 300; + this.hboxError.Hide(); + this.Show(); + this.buttonClose.Clicked += new System.EventHandler(this.CloseClicked); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.ShowTextDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.ShowTextDialog.cs new file mode 100644 index 0000000000..53a7e7058b --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.ShowTextDialog.cs @@ -0,0 +1,63 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Components { + + + public partial class ShowTextDialog { + + private Gtk.VBox vboxContent; + + private Gtk.Button button462; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Components.ShowTextDialog + this.Name = "MonoDevelop.Database.Components.ShowTextDialog"; + this.Title = Mono.Unix.Catalog.GetString("Text"); + this.TypeHint = ((Gdk.WindowTypeHint)(1)); + this.WindowPosition = ((Gtk.WindowPosition)(1)); + this.SkipTaskbarHint = true; + this.HasSeparator = false; + // Internal child MonoDevelop.Database.Components.ShowTextDialog.VBox + Gtk.VBox w1 = this.VBox; + w1.Name = "vbox"; + w1.BorderWidth = ((uint)(2)); + // Container child vbox.Gtk.Box+BoxChild + this.vboxContent = new Gtk.VBox(); + this.vboxContent.Name = "vboxContent"; + this.vboxContent.Spacing = 6; + this.vboxContent.BorderWidth = ((uint)(6)); + w1.Add(this.vboxContent); + Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(w1[this.vboxContent])); + w2.Position = 0; + // Internal child MonoDevelop.Database.Components.ShowTextDialog.ActionArea + Gtk.HButtonBox w3 = this.ActionArea; + w3.Name = "GtkDialog_ActionArea"; + w3.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); + // Container child GtkDialog_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.button462 = new Gtk.Button(); + this.button462.CanFocus = true; + this.button462.Name = "button462"; + this.button462.UseUnderline = true; + this.button462.Label = Mono.Unix.Catalog.GetString("button462"); + this.AddActionWidget(this.button462, 0); + Gtk.ButtonBox.ButtonBoxChild w4 = ((Gtk.ButtonBox.ButtonBoxChild)(w3[this.button462])); + w4.Expand = false; + w4.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.DefaultWidth = 400; + this.DefaultHeight = 300; + this.Show(); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.SqlEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.SqlEditorWidget.cs new file mode 100644 index 0000000000..1a5826f4a0 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.SqlEditorWidget.cs @@ -0,0 +1,37 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Components { + + + public partial class SqlEditorWidget { + + private Gtk.ScrolledWindow scrolledwindow; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Components.SqlEditorWidget + Stetic.BinContainer.Attach(this); + this.Name = "MonoDevelop.Database.Components.SqlEditorWidget"; + // Container child MonoDevelop.Database.Components.SqlEditorWidget.Gtk.Container+ContainerChild + this.scrolledwindow = new Gtk.ScrolledWindow(); + this.scrolledwindow.CanFocus = true; + this.scrolledwindow.Name = "scrolledwindow"; + this.scrolledwindow.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindow.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindow.ShadowType = ((Gtk.ShadowType)(1)); + this.Add(this.scrolledwindow); + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.Show(); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.WaitDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.WaitDialog.cs new file mode 100644 index 0000000000..d6491569f8 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/MonoDevelop.Database.Components.WaitDialog.cs @@ -0,0 +1,90 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Components { + + + public partial class WaitDialog { + + private Gtk.VBox vbox; + + private Gtk.HBox hbox2; + + private Gtk.Image image; + + private Gtk.Label label; + + private Gtk.ProgressBar progressbar; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Components.WaitDialog + this.Name = "MonoDevelop.Database.Components.WaitDialog"; + this.Title = Mono.Unix.Catalog.GetString("WaitDialog"); + this.TypeHint = ((Gdk.WindowTypeHint)(6)); + this.WindowPosition = ((Gtk.WindowPosition)(1)); + this.Modal = true; + this.BorderWidth = ((uint)(1)); + this.Resizable = false; + this.AllowGrow = false; + this.Decorated = false; + this.SkipTaskbarHint = true; + // Container child MonoDevelop.Database.Components.WaitDialog.Gtk.Container+ContainerChild + this.vbox = new Gtk.VBox(); + this.vbox.Name = "vbox"; + this.vbox.Spacing = 6; + this.vbox.BorderWidth = ((uint)(6)); + // Container child vbox.Gtk.Box+BoxChild + this.hbox2 = new Gtk.HBox(); + this.hbox2.Name = "hbox2"; + this.hbox2.Spacing = 6; + // Container child hbox2.Gtk.Box+BoxChild + this.image = new Gtk.Image(); + this.image.Name = "image"; + this.image.Xalign = 0F; + this.image.Yalign = 0F; + this.image.Pixbuf = Stetic.IconLoader.LoadIcon(this, "stock_alarm", Gtk.IconSize.Dialog, 48); + this.hbox2.Add(this.image); + Gtk.Box.BoxChild w1 = ((Gtk.Box.BoxChild)(this.hbox2[this.image])); + w1.Position = 0; + w1.Expand = false; + w1.Fill = false; + // Container child hbox2.Gtk.Box+BoxChild + this.label = new Gtk.Label(); + this.label.Name = "label"; + this.label.Xalign = 0F; + this.label.Yalign = 0F; + this.label.LabelProp = Mono.Unix.Catalog.GetString("Please wait"); + this.hbox2.Add(this.label); + Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.hbox2[this.label])); + w2.Position = 1; + this.vbox.Add(this.hbox2); + Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.vbox[this.hbox2])); + w3.Position = 0; + w3.Expand = false; + w3.Fill = false; + // Container child vbox.Gtk.Box+BoxChild + this.progressbar = new Gtk.ProgressBar(); + this.progressbar.Name = "progressbar"; + this.vbox.Add(this.progressbar); + Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.vbox[this.progressbar])); + w4.Position = 1; + w4.Expand = false; + w4.Fill = false; + this.Add(this.vbox); + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.DefaultWidth = 400; + this.DefaultHeight = 114; + this.Show(); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/generated.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/generated.cs new file mode 100644 index 0000000000..ebb1662eb0 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/generated.cs @@ -0,0 +1,115 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace Stetic { + + + internal class Gui { + + private static bool initialized; + + internal static void Initialize(Gtk.Widget iconRenderer) { + if ((Stetic.Gui.initialized == false)) { + Stetic.Gui.initialized = true; + } + } + } + + internal class BinContainer { + + private Gtk.Widget child; + + private Gtk.UIManager uimanager; + + public static BinContainer Attach(Gtk.Bin bin) { + BinContainer bc = new BinContainer(); + bin.SizeRequested += new Gtk.SizeRequestedHandler(bc.OnSizeRequested); + bin.SizeAllocated += new Gtk.SizeAllocatedHandler(bc.OnSizeAllocated); + bin.Added += new Gtk.AddedHandler(bc.OnAdded); + return bc; + } + + private void OnSizeRequested(object sender, Gtk.SizeRequestedArgs args) { + if ((this.child != null)) { + args.Requisition = this.child.SizeRequest(); + } + } + + private void OnSizeAllocated(object sender, Gtk.SizeAllocatedArgs args) { + if ((this.child != null)) { + this.child.Allocation = args.Allocation; + } + } + + private void OnAdded(object sender, Gtk.AddedArgs args) { + this.child = args.Widget; + } + + public void SetUiManager(Gtk.UIManager uim) { + this.uimanager = uim; + this.child.Realized += new System.EventHandler(this.OnRealized); + } + + private void OnRealized(object sender, System.EventArgs args) { + if ((this.uimanager != null)) { + Gtk.Widget w; + w = this.child.Toplevel; + if (((w != null) && typeof(Gtk.Window).IsInstanceOfType(w))) { + ((Gtk.Window)(w)).AddAccelGroup(this.uimanager.AccelGroup); + this.uimanager = null; + } + } + } + } + + internal class IconLoader { + + public static Gdk.Pixbuf LoadIcon(Gtk.Widget widget, string name, Gtk.IconSize size, int sz) { + Gdk.Pixbuf res = widget.RenderIcon(name, size, null); + if ((res != null)) { + return res; + } + else { + try { + return Gtk.IconTheme.Default.LoadIcon(name, sz, 0); + } + catch (System.Exception ) { + if ((name != "gtk-missing-image")) { + return Stetic.IconLoader.LoadIcon(widget, "gtk-missing-image", size, sz); + } + else { + Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, sz, sz); + Gdk.GC gc = new Gdk.GC(pmap); + gc.RgbFgColor = new Gdk.Color(255, 255, 255); + pmap.DrawRectangle(gc, true, 0, 0, sz, sz); + gc.RgbFgColor = new Gdk.Color(0, 0, 0); + pmap.DrawRectangle(gc, false, 0, 0, (sz - 1), (sz - 1)); + gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round); + gc.RgbFgColor = new Gdk.Color(255, 0, 0); + pmap.DrawLine(gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4))); + pmap.DrawLine(gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4))); + return Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz); + } + } + } + } + } + + internal class ActionGroups { + + public static Gtk.ActionGroup GetActionGroup(System.Type type) { + return Stetic.ActionGroups.GetActionGroup(type.FullName); + } + + public static Gtk.ActionGroup GetActionGroup(string name) { + return null; + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/gui.stetic b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/gui.stetic new file mode 100644 index 0000000000..5cc32b31eb --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/gui.stetic @@ -0,0 +1,1170 @@ +<?xml version="1.0" encoding="utf-8"?> +<stetic-interface> + <configuration> + <images-root-path>../</images-root-path> + <target-gtk-version>2.8.3</target-gtk-version> + </configuration> + <import> + <widget-library name="../../../../build/bin/MonoDevelop.Components.dll" /> + <widget-library name="../../../../build/bin/MonoDevelop.Ide.dll" /> + <widget-library name="../../../../build/bin/MonoDevelop.Projects.Gui.dll" /> + <widget-library name="../../../../build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Components.dll" internal="true" /> + </import> + <widget class="Gtk.Dialog" id="MonoDevelop.Database.Components.SelectColumnDialog" design-size="400 300"> + <property name="MemberName" /> + <property name="Title" translatable="yes">Select Column</property> + <property name="TypeHint">Dialog</property> + <property name="WindowPosition">Center</property> + <property name="DestroyWithParent">True</property> + <property name="SkipTaskbarHint">True</property> + <property name="Buttons">2</property> + <property name="HelpButton">False</property> + <property name="HasSeparator">False</property> + <child internal-child="VBox"> + <widget class="Gtk.VBox" id="Dialog_Vbox"> + <property name="MemberName">vbox</property> + <property name="BorderWidth">2</property> + <child> + <widget class="Gtk.HBox" id="hboxContent"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <placeholder /> + </child> + <child> + <widget class="Gtk.VButtonBox" id="vbuttonbox1"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="Size">2</property> + <property name="LayoutStyle">Start</property> + <child> + <widget class="Gtk.Button" id="buttonSelectAll"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Type">TextOnly</property> + <property name="Label" translatable="yes">Select All</property> + <property name="UseUnderline">True</property> + <signal name="Clicked" handler="SelectAllClicked" /> + </widget> + <packing> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonDeselectAll"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Type">TextOnly</property> + <property name="Label" translatable="yes">Deselect All</property> + <property name="UseUnderline">True</property> + <signal name="Clicked" handler="DeselectAllClicked" /> + </widget> + <packing> + <property name="Position">1</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="PackType">End</property> + <property name="Position">1</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + </packing> + </child> + </widget> + </child> + <child internal-child="ActionArea"> + <widget class="Gtk.HButtonBox" id="GtkDialog_ActionArea"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="BorderWidth">5</property> + <property name="Size">2</property> + <property name="LayoutStyle">End</property> + <child> + <widget class="Gtk.Button" id="buttonCancel"> + <property name="MemberName" /> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-cancel</property> + <property name="ResponseId">-6</property> + <property name="label">gtk-cancel</property> + </widget> + <packing> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonOk"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-ok</property> + <property name="ResponseId">-5</property> + <property name="label">gtk-ok</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Bin" id="MonoDevelop.Database.Components.DataGrid" design-size="737 300"> + <property name="MemberName" /> + <child> + <widget class="Gtk.VBox" id="vbox"> + <property name="MemberName" /> + <property name="Spacing">5</property> + <property name="BorderWidth">5</property> + <child> + <widget class="Gtk.ScrolledWindow" id="scrolledwindow"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <child> + <widget class="Gtk.TreeView" id="grid"> + <property name="MemberName" /> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="EnableSearch">False</property> + <property name="HeadersClickable">True</property> + </widget> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + </packing> + </child> + <child> + <widget class="Gtk.HBox" id="hbox"> + <property name="MemberName" /> + <property name="Spacing">5</property> + <child> + <widget class="Gtk.Button" id="buttonFirst"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-goto-first</property> + <signal name="Clicked" handler="ButtonFirstClicked" /> + <property name="label">gtk-goto-first</property> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonPrevious"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-go-back</property> + <signal name="Clicked" handler="ButtonPreviousClicked" /> + <property name="label">gtk-go-back</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Entry" id="entryCurrent"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="IsEditable">True</property> + <property name="InvisibleChar">●</property> + <property name="Xalign">0.5</property> + <signal name="Activated" handler="EntryCurrentActivated" /> + </widget> + <packing> + <property name="Position">2</property> + <property name="AutoSize">False</property> + <property name="Expand">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="label1"> + <property name="MemberName" /> + <property name="LabelProp" translatable="yes">of</property> + </widget> + <packing> + <property name="Position">3</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Entry" id="entryTotal"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="IsEditable">False</property> + <property name="InvisibleChar">●</property> + <property name="Xalign">0.5</property> + </widget> + <packing> + <property name="Position">4</property> + <property name="AutoSize">False</property> + <property name="Expand">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonNext"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-go-forward</property> + <signal name="Clicked" handler="ButtonNextClicked" /> + <property name="label">gtk-go-forward</property> + </widget> + <packing> + <property name="Position">5</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonLast"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-goto-last</property> + <signal name="Clicked" handler="ButtonLastClicked" /> + <property name="label">gtk-goto-last</property> + </widget> + <packing> + <property name="Position">6</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <placeholder /> + </child> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Dialog" id="MonoDevelop.Database.Components.ShowImageDialog" design-size="400 300"> + <property name="MemberName" /> + <property name="Title" translatable="yes">Image</property> + <property name="TypeHint">Dialog</property> + <property name="WindowPosition">Center</property> + <property name="SkipTaskbarHint">True</property> + <property name="Buttons">1</property> + <property name="HelpButton">False</property> + <property name="HasSeparator">False</property> + <child internal-child="VBox"> + <widget class="Gtk.VBox" id="dialog1_VBox"> + <property name="MemberName" /> + <property name="BorderWidth">2</property> + <child> + <widget class="Gtk.ScrolledWindow" id="scrolledwindow"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <child> + <widget class="Gtk.Viewport" id="GtkViewport"> + <property name="MemberName" /> + <property name="ShadowType">None</property> + <child> + <widget class="Gtk.Image" id="image1"> + <property name="MemberName" /> + </widget> + </child> + </widget> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + </packing> + </child> + <child> + <widget class="Gtk.HBox" id="hboxError"> + <property name="MemberName">hboxError</property> + <property name="Visible">False</property> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.Image" id="image"> + <property name="MemberName" /> + <property name="Pixbuf">stock:gtk-dialog-error Menu</property> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="label"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Unable to load object as Image</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + </child> + <child internal-child="ActionArea"> + <widget class="Gtk.HButtonBox" id="dialog1_ActionArea"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="BorderWidth">5</property> + <property name="Size">1</property> + <property name="LayoutStyle">End</property> + <child> + <widget class="Gtk.Button" id="buttonClose"> + <property name="MemberName" /> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-close</property> + <property name="ResponseId">-7</property> + <signal name="Clicked" handler="CloseClicked" /> + <property name="label">gtk-close</property> + </widget> + <packing> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Dialog" id="MonoDevelop.Database.Components.ShowTextDialog" design-size="400 300"> + <property name="MemberName" /> + <property name="Title" translatable="yes">Text</property> + <property name="TypeHint">Dialog</property> + <property name="WindowPosition">Center</property> + <property name="SkipTaskbarHint">True</property> + <property name="Buttons">1</property> + <property name="HelpButton">False</property> + <property name="HasSeparator">False</property> + <child internal-child="VBox"> + <widget class="Gtk.VBox" id="vbox"> + <property name="MemberName">vbox</property> + <property name="BorderWidth">2</property> + <child> + <widget class="Gtk.VBox" id="vboxContent"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="BorderWidth">6</property> + <child> + <placeholder /> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + </packing> + </child> + </widget> + </child> + <child internal-child="ActionArea"> + <widget class="Gtk.HButtonBox" id="GtkDialog_ActionArea"> + <property name="MemberName" /> + <property name="Size">1</property> + <property name="LayoutStyle">End</property> + <child> + <widget class="Gtk.Button" id="button462"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Type">TextOnly</property> + <property name="Label" translatable="yes">button462</property> + <property name="UseUnderline">True</property> + <property name="ResponseId">0</property> + </widget> + <packing> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Dialog" id="MonoDevelop.Database.Components.DatabaseConnectionSettingsDialog" design-size="606 351"> + <property name="MemberName" /> + <property name="TypeHint">Dialog</property> + <property name="WindowPosition">Center</property> + <property name="SkipTaskbarHint">True</property> + <property name="Buttons">2</property> + <property name="HelpButton">False</property> + <property name="HasSeparator">False</property> + <child internal-child="VBox"> + <widget class="Gtk.VBox" id="dialog1_VBox"> + <property name="MemberName" /> + <property name="BorderWidth">2</property> + <child> + <widget class="Gtk.Notebook" id="notebook"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="CurrentPage">0</property> + <child> + <widget class="Gtk.Table" id="tableGeneral"> + <property name="MemberName" /> + <property name="NRows">7</property> + <property name="NColumns">2</property> + <property name="RowSpacing">6</property> + <property name="ColumnSpacing">6</property> + <property name="BorderWidth">6</property> + <child> + <widget class="Gtk.ComboBox" id="comboProvider"> + <property name="MemberName" /> + <property name="IsTextCombo">False</property> + <property name="Items" translatable="yes" /> + <signal name="Changed" handler="ProviderChanged" /> + </widget> + <packing> + <property name="LeftAttach">1</property> + <property name="RightAttach">2</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Entry" id="entryName"> + <property name="MemberName" /> + <property name="CanDefault">True</property> + <property name="HasDefault">True</property> + <property name="CanFocus">True</property> + <property name="IsEditable">True</property> + <property name="ActivatesDefault">True</property> + <property name="InvisibleChar">●</property> + <signal name="Changed" handler="NameChanged" /> + </widget> + <packing> + <property name="TopAttach">1</property> + <property name="BottomAttach">2</property> + <property name="LeftAttach">1</property> + <property name="RightAttach">2</property> + <property name="AutoSize">False</property> + <property name="YOptions">Fill</property> + <property name="XExpand">True</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Entry" id="entryServer"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="IsEditable">True</property> + <property name="InvisibleChar">●</property> + <signal name="Changed" handler="ServerChanged" /> + </widget> + <packing> + <property name="TopAttach">2</property> + <property name="BottomAttach">3</property> + <property name="LeftAttach">1</property> + <property name="RightAttach">2</property> + <property name="AutoSize">False</property> + <property name="YOptions">Fill</property> + <property name="XExpand">True</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Entry" id="entryUsername"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="IsEditable">True</property> + <property name="InvisibleChar">●</property> + <signal name="Changed" handler="UsernameChanged" /> + </widget> + <packing> + <property name="TopAttach">4</property> + <property name="BottomAttach">5</property> + <property name="LeftAttach">1</property> + <property name="RightAttach">2</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.HBox" id="hboxDatabase"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.ComboBoxEntry" id="comboDatabase"> + <property name="MemberName" /> + <property name="IsTextCombo">True</property> + <property name="Items" translatable="yes" /> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonRefresh"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-refresh</property> + <signal name="Clicked" handler="RefreshClicked" /> + <property name="label">gtk-refresh</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonOpen"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-open</property> + <signal name="Clicked" handler="OpenClicked" /> + <property name="label">gtk-open</property> + </widget> + <packing> + <property name="Position">2</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="TopAttach">6</property> + <property name="BottomAttach">7</property> + <property name="LeftAttach">1</property> + <property name="RightAttach">2</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.HBox" id="hboxPassword"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.Entry" id="entryPassword"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="IsEditable">True</property> + <property name="Visibility">False</property> + <property name="InvisibleChar">●</property> + <signal name="Changed" handler="PasswordChanged" /> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + </packing> + </child> + <child> + <widget class="Gtk.CheckButton" id="checkSavePassword"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Label" translatable="yes">Save Password</property> + <property name="Active">True</property> + <property name="DrawIndicator">True</property> + <property name="HasLabel">True</property> + <property name="UseUnderline">True</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">False</property> + <property name="Expand">False</property> + </packing> + </child> + </widget> + <packing> + <property name="TopAttach">5</property> + <property name="BottomAttach">6</property> + <property name="LeftAttach">1</property> + <property name="RightAttach">2</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="label3"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Type</property> + </widget> + <packing> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="label4"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Name</property> + </widget> + <packing> + <property name="TopAttach">1</property> + <property name="BottomAttach">2</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="label5"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Server</property> + </widget> + <packing> + <property name="TopAttach">2</property> + <property name="BottomAttach">3</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="label6"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Port</property> + </widget> + <packing> + <property name="TopAttach">3</property> + <property name="BottomAttach">4</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="label7"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Username</property> + </widget> + <packing> + <property name="TopAttach">4</property> + <property name="BottomAttach">5</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="label8"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Password</property> + </widget> + <packing> + <property name="TopAttach">5</property> + <property name="BottomAttach">6</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="label9"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Database</property> + </widget> + <packing> + <property name="TopAttach">6</property> + <property name="BottomAttach">7</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.SpinButton" id="spinPort"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Lower">1</property> + <property name="Upper">65535</property> + <property name="PageIncrement">10</property> + <property name="StepIncrement">1</property> + <property name="ClimbRate">1</property> + <property name="Numeric">True</property> + <property name="Value">1</property> + <signal name="Changed" handler="PortChanged" /> + </widget> + <packing> + <property name="TopAttach">3</property> + <property name="BottomAttach">4</property> + <property name="LeftAttach">1</property> + <property name="RightAttach">2</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + </widget> + <packing> + <property name="TabExpand">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="label1"> + <property name="MemberName" /> + <property name="LabelProp" translatable="yes">General</property> + </widget> + <packing> + <property name="type">tab</property> + </packing> + </child> + <child> + <widget class="Gtk.Table" id="tableAdvanced"> + <property name="MemberName" /> + <property name="NRows">4</property> + <property name="NColumns">2</property> + <property name="RowSpacing">6</property> + <property name="ColumnSpacing">6</property> + <property name="BorderWidth">6</property> + <child> + <widget class="Gtk.CheckButton" id="checkCustom"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Label" translatable="yes">Use custom connection string</property> + <property name="DrawIndicator">True</property> + <property name="HasLabel">True</property> + <property name="UseUnderline">True</property> + </widget> + <packing> + <property name="TopAttach">2</property> + <property name="BottomAttach">3</property> + <property name="RightAttach">2</property> + <property name="AutoSize">False</property> + <property name="YOptions">Fill</property> + <property name="XExpand">True</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="label10"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Min Pool Size</property> + </widget> + <packing> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="label11"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Max Pool Size</property> + </widget> + <packing> + <property name="TopAttach">1</property> + <property name="BottomAttach">2</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.ScrolledWindow" id="scrolledwindow"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanFocus">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <child> + <widget class="Gtk.TextView" id="textConnectionString"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Text" translatable="yes" /> + </widget> + </child> + </widget> + <packing> + <property name="TopAttach">3</property> + <property name="BottomAttach">4</property> + <property name="RightAttach">2</property> + <property name="AutoSize">False</property> + <property name="YOptions">Fill</property> + <property name="XExpand">True</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.SpinButton" id="spinMaxPoolSize"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Lower">1</property> + <property name="Upper">100</property> + <property name="PageIncrement">10</property> + <property name="StepIncrement">1</property> + <property name="ClimbRate">1</property> + <property name="Numeric">True</property> + <property name="Value">5</property> + <signal name="Changed" handler="MaxPoolSizeChanged" /> + </widget> + <packing> + <property name="TopAttach">1</property> + <property name="BottomAttach">2</property> + <property name="LeftAttach">1</property> + <property name="RightAttach">2</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.SpinButton" id="spinMinPoolSize"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Lower">1</property> + <property name="Upper">100</property> + <property name="PageIncrement">10</property> + <property name="StepIncrement">1</property> + <property name="ClimbRate">1</property> + <property name="Numeric">True</property> + <property name="Value">1</property> + <signal name="Changed" handler="MinPoolSizeChanged" /> + </widget> + <packing> + <property name="LeftAttach">1</property> + <property name="RightAttach">2</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">1</property> + <property name="TabExpand">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="label2"> + <property name="MemberName" /> + <property name="LabelProp" translatable="yes">Advanced</property> + </widget> + <packing> + <property name="type">tab</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + </child> + <child internal-child="ActionArea"> + <widget class="Gtk.HButtonBox" id="dialog1_ActionArea"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="BorderWidth">5</property> + <property name="Size">2</property> + <property name="LayoutStyle">End</property> + <child> + <widget class="Gtk.Button" id="buttonCancel"> + <property name="MemberName" /> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-cancel</property> + <property name="ResponseId">-6</property> + <signal name="Clicked" handler="OnCancelClicked" /> + <property name="label">gtk-cancel</property> + </widget> + <packing> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonOk"> + <property name="MemberName" /> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-ok</property> + <property name="ResponseId">-5</property> + <signal name="Clicked" handler="OnOkClicked" /> + <property name="label">gtk-ok</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Window" id="MonoDevelop.Database.Components.WaitDialog" design-size="400 114"> + <property name="MemberName" /> + <property name="Title" translatable="yes">WaitDialog</property> + <property name="TypeHint">Dock</property> + <property name="WindowPosition">Center</property> + <property name="Modal">True</property> + <property name="BorderWidth">1</property> + <property name="Resizable">False</property> + <property name="AllowGrow">False</property> + <property name="Decorated">False</property> + <property name="SkipTaskbarHint">True</property> + <child> + <widget class="Gtk.VBox" id="vbox"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="BorderWidth">6</property> + <child> + <widget class="Gtk.HBox" id="hbox2"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.Image" id="image"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="Yalign">0</property> + <property name="Pixbuf">stock:stock_alarm Dialog</property> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="label"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="Yalign">0</property> + <property name="LabelProp" translatable="yes">Please wait</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.ProgressBar" id="progressbar"> + <property name="MemberName" /> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Bin" id="MonoDevelop.Database.Components.SqlEditorWidget" design-size="300 300"> + <property name="MemberName" /> + <child> + <widget class="Gtk.ScrolledWindow" id="scrolledwindow"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <child> + <widget class="Gtk.Viewport" id="GtkViewport"> + <property name="MemberName" /> + <property name="ShadowType">None</property> + <child> + <placeholder /> + </child> + </widget> + </child> + </widget> + </child> + </widget> +</stetic-interface>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/objects.xml b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/objects.xml new file mode 100644 index 0000000000..9173bc37dc --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Components/gtk-gui/objects.xml @@ -0,0 +1,39 @@ +<objects> + <object type="MonoDevelop.Database.Components.ProjectDirectoryComboBox" palette-category="widget" allow-children="false" base-type="Gtk.ComboBox"> + <itemgroups /> + <signals /> + </object> + <object type="MonoDevelop.Database.Components.ColumnMappingWidget" palette-category="widget" allow-children="false" base-type="Gtk.ScrolledWindow"> + <itemgroups /> + <signals /> + </object> + <object type="MonoDevelop.Database.Components.DatabaseConnectionContextComboBox" palette-category="widget" allow-children="false" base-type="Gtk.ComboBox"> + <itemgroups /> + <signals /> + </object> + <object type="MonoDevelop.Database.Components.SelectColumnWidget" palette-category="widget" allow-children="false" base-type="Gtk.ScrolledWindow"> + <itemgroups> + <itemgroup label="SelectColumnWidget Properties"> + <property name="SingleCheck" /> + </itemgroup> + </itemgroups> + <signals> + <itemgroup label="SelectColumnWidget Signals"> + <signal name="ColumnToggled" /> + </itemgroup> + </signals> + </object> + <object type="MonoDevelop.Database.Components.SqlEditorWidget" palette-category="widget" allow-children="false" base-type="Gtk.Bin"> + <itemgroups> + <itemgroup label="SqlEditorWidget Properties"> + <property name="Text" /> + <property name="Editable" /> + </itemgroup> + </itemgroups> + <signals> + <itemgroup label="SqlEditorWidget Signals"> + <signal name="TextChanged" /> + </itemgroup> + </signals> + </object> +</objects>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/AssemblyInfo.cs.in b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/AssemblyInfo.cs.in new file mode 100644 index 0000000000..9e0952694b --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/AssemblyInfo.cs.in @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("Mono.Data.ConnectionManager")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("http://www.monodevelop.com")] +[assembly: AssemblyCopyright("MIT X11 - Christian Hergert, Ben Motmans")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: AssemblyVersion("@ASSEMBLY_VERSION@")] + +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")]
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/ChangeLog b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/ChangeLog new file mode 100644 index 0000000000..90e6d7f53c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/ChangeLog @@ -0,0 +1,183 @@ +2007-11-09 Michael Hutchinson <mhutchinson@novell.com> + + * NodeBuilders/TablesNodeBuilder.cs, + NodeBuilders/ConnectionContextCollectionNodeBuilder.cs: Track + LoggingService API. Replace some "LogError" calls with "LogDebug" calls. + +2007-10-29 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.ConnectionManager.addin.xml: Bump MD version. + +2007-10-23 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.ConnectionManager.mdp: Project file names updated by + change in MD path functions. + +2007-10-16 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.ConnectionManager.mdp: Fix required GTK# version. + +2007-09-26 Michael Hutchinson <mhutchinson@novell.com> + + * MonoDevelop.Database.ConnectionManager.mdp: Don't unnecessarily local-copy + project references. Don't sync EXTRA_DIST with deploy files. Add + Makefile.am to file list. + * Makefile.am: Don't deploy .addin.xml file. + +2007-09-21 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.ConnectionManager.addin.xml: Bump MD version. + +2007-09-19 Ben Motmans <ben.motmans@gmail.com> + + * NodeBuilders/ViewNodeBuilder.cs, NodeBuilders/ProcedureNodeBuilder.cs: + only show child nodes if supported by the provider + +2007-09-16 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: link to the correct Mono.Addins dll + +2007-09-07 Ben Motmans <ben.motmans@gmail.com> + + * NodeBuilders/UsersNodeBuilder.cs, + NodeBuilders/ConnectionContextNodeBuilder.cs, + NodeBuilders/TablesNodeBuilder.cs, NodeBuilders/ViewNodeBuilder.cs, + NodeBuilders/ProceduresNodeBuilder.cs, NodeBuilders/UserNodeBuilder.cs, + NodeBuilders/TriggersNodeBuilder.cs, NodeBuilders/TableNodeBuilder.cs, + NodeBuilders/ProcedureNodeBuilder.cs, NodeBuilders/ViewsNodeBuilder.cs, + NodeBuilders/ColumnNodeBuilder.cs: improved capabilities system + * ConnectionManagerPad.cs: removed unneeded using statement + +2007-08-29 Ben Motmans <ben.motmans@gmail.com> + + * MonoDevelop.Database.ConnectionManager.addin.xml: updated + ExtensionNodeSets + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * MonoDevelop.Database.ConnectionManager.mdp, Makefile.am: use project + references instead of assembly references + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * NodeBuilders/UsersNodeBuilder.cs, NodeBuilders/ParametersNodeBuilder.cs, + NodeBuilders/TypesNodeBuilder.cs, + NodeBuilders/ConnectionContextNodeBuilder.cs, + NodeBuilders/LanguagesNodeBuilder.cs, + NodeBuilders/ConstraintsNodeBuilder.cs, + NodeBuilders/AggregatesNodeBuilder.cs, NodeBuilders/ViewNodeBuilder.cs, + NodeBuilders/TablesNodeBuilder.cs, + NodeBuilders/ProceduresNodeBuilder.cs, + NodeBuilders/OperatorsNodeBuilder.cs, NodeBuilders/GroupsNodeBuilder.cs, + NodeBuilders/ConnectionContextCollectionNodeBuilder.cs, + NodeBuilders/ColumnsNodeBuilder.cs, + NodeBuilders/ParameterNodeBuilder.cs, + NodeBuilders/ConstraintNodeBuilder.cs, NodeBuilders/RolesNodeBuilder.cs, + NodeBuilders/TriggersNodeBuilder.cs, NodeBuilders/TableNodeBuilder.cs, + NodeBuilders/ProcedureNodeBuilder.cs, NodeBuilders/RulesNodeBuilder.cs, + NodeBuilders/SequencesNodeBuilder.cs, NodeBuilders/ViewsNodeBuilder.cs, + NodeBuilders/ColumnNodeBuilder.cs, + MonoDevelop.Database.ConnectionManager.addin.xml: updated addin paths + * Makefile.am: updated makefile + +2007-08-03 Ben Motmans <ben.motmans@gmail.com> + + * NodeBuilders/*: various fixes for refreshing nodes + + * NodeBuilders/ConnectionContextNodeBuilder.cs: Added a connect command and correctly implemented + the DropDatabase command + * use the DispatchService as a static class instead of a service + +2007-08-02 Ben Motmans <ben.motmans@gmail.com> + + * NodeBuilders/ViewNodeBuilder.cs, NodeBuilders/UserNodeBuilder.cs, + NodeBuilders/TableNodeBuilder.cs, NodeBuilders/ProcedureNodeBuilder.cs, + NodeBuilders/ConnectionContextNodeBuilder.cs: fixed rename objects in the tree + +2007-08-01 Ben Motmans <ben.motmans@gmail.com> + + * NodeBuilders/*.cs: no longer uses the NodeState object but Context.GetTreeBuilder + to get the ITreeBuilder for a specific node + + * NodeBuilders/TableNodeBuilder.cs: use a bg thread Select* methods + * NodeBuilders/ConstraintsNodeBuilder.cs, NodeBuilders/ColumnNodeBuilder.cs: added support for column constraints + * ConnectionManagerCommands.cs, NodeBuilders/ConnectionContextCollectionNodeBuilder.cs: + moved AddConnection command into the nodebuilder + * ConnectionManagerPad.cs: ConnectionContextService is now automatically initialized + * MonoDevelop.Database.ConnectionManager.addin.xml: commented out a command since it caused problems + +2007-07-31 Ben Motmans <ben.motmans@gmail.com> + + * NodeBuilders/*.cs: Make use of the GuiProvider to show Gui dialogs + +2007-07-25 Ben Motmans <ben.motmans@gmail.com> + + * NodeBuilders/ProceduresNodeBuilder.cs, NodeBuilders/TablesNodeBuilder.cs, + NodeBuilders/UsersNodeBuilder.cs, NodeBuilders/ViewsNodeBuilder.cs: + implemented create command + * NodeBuilders/ProcedureNodeBuilder.cs, NodeBuilders/TableNodeBuilder.cs, + NodeBuilders/UserNodeBuilder.cs, NodeBuilders/ViewNodeBuilder.cs: + implemented drop, rename and refresh commands + * NodeBuilders/ConnectionContextNodeBuilder.cs: use the new schemaprovider metadata support + * NodeBuilders/ConnectionContextCollectionNodeBuilder.cs: implemented CreateDatabase + +2007-07-18 Ben Motmans <ben.motmans@gmail.com> + + * NodeBuilders/ViewNodeBuilder.cs, NodeBuilders/UserNodeBuilder.cs, + NodeBuilders/TableNodeBuilder.cs, NodeBuilders/ProcedureNodeBuilder.cs, + NodeBuilders/ParametersNodeBuilder.cs: Added CommandHandlers and CommandUpdateHandlers + * NodeBuilders/ConnectionContextNodeBuilder.cs, NodeBuilders/ConstraintsNodeBuilder.cs + NodeBuilders/ProceduresNodeBuilder.cs, NodeBuilders/TablesNodeBuilder.cs, + NodeBuilders/UsersNodeBuilder.cs, NodeBuilders/ViewsNodeBuilder.cs, + NodeBuilders/TriggersNodeBuilder.cs: added CommandUpdateHandlers + * NodeBuilders/ConnectionContextCollectionNodeBuilder.cs: added a NodeCommandHandler + * ConnectionManagerCommands.cs: Create, Alter, Drop and Rename Schema commands + * MonoDevelop.Database.ConnectionManager.addin.xml: Added ExtensionPoints for all NodeBuilders + and added CommandItems for all ConnectionManagerCommands + +2007-07-17 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: initial makefile + * ConnectionManagerCommands.cs: added CreateXXX, DropXXX, AlterXXX, RenameXXX commands + * NodeBuilders/AggregatesNodeBuilder.cs, NodeBuilders/ColumnNodeBuilder.cs, + NodeBuilders/ColumnsNodeBuilder.cs, NodeBuilders/ConnectionContextCollectionNodeBuilder.cs, + NodeBuilders/ConnectionContextNodeBuilder.cs, NodeBuilders/ConstraintNodeBuilder.cs, + NodeBuilders/ConstraintsNodeBuilder.cs, NodeBuilders/GroupsNodeBuilder.cs, + NodeBuilders/LanguagesNodeBuilder.cs, NodeBuilders/OperatorsNodeBuilder.cs, + NodeBuilders/ParameterNodeBuilder.cs, NodeBuilders/ParametersNodeBuilder.cs, + NodeBuilders/RolesNodeBuilder.cs, NodeBuilders/RulesNodeBuilder.cs, + NodeBuilders/SequencesNodeBuilder.cs, NodeBuilders/TriggersNodeBuilder.cs, + NodeBuilders/TypesNodeBuilder.cs: initial implementation + * NodeBuilders/ProcedureNodeBuilder.cs, NodeBuilders/ProceduresNodeBuilder.cs, + NodeBuilders/TableNodeBuilder.cs, NodeBuilders/TablesNodeBuilder.cs, + NodeBuilders/ViewNodeBuilder.cs, NodeBuilders/ViewsNodeBuilder.cs, + NodeBuilders/UserNodeBuilder.cs, NodeBuilders/UsersNodeBuilder.cs: + Updated to use the new NodeState object when doing Async method calls + * MonoDevelop.Database.ConnectionManager.addin.xml: added nodebuilder extension items + * NodeState.cs: internal class to store the state when doing async calls in the connection manager pad + +2007-07-14 Ben Motmans <ben.motmans@gmail.com> + + * NodeBuilders/*.cs: small changes due to updated Mono.Data.Sql API + +2007-07-10 Ben Motmans <ben.motmans@gmail.com> + + * NewConnectionDialog.cs: moved to Components project + * NodeBuilders/*.cs: bugfixes + command implementations + * FakeNodes.cs: Refresh event + additional properties in some fake nodes + +2007-07-05 Ben Motmans <ben.motmans@gmail.com> + + * NewConnectionDialog.cs: small bugfixes + * FakeNodes.cs: dummy nodes to use in the TreeBuilder + * Commands.cs: list of commends and AddConnection implementation + * ConnectionManagerService.cs: service to load/save connection settings + * ConnectionManagerPad.cs, NodeBuilders/*.cs: update of the old code, + make use of ThreadPool instead of always creating new threads + use + the updated Mono.Data.Sql API + +2007-07-02 Ben Motmans <ben.motmans@gmail.com> + + * NewConnectionDialog.cs: Remake of the old dialog using the integrated MD designer, + the new dialog also includes pooling options + diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/ConnectionManagerCommands.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/ConnectionManagerCommands.cs new file mode 100644 index 0000000000..090883ad6c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/ConnectionManagerCommands.cs @@ -0,0 +1,81 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Gtk; +using System; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.ConnectionManager +{ + public enum ConnectionManagerCommands + { + AddConnection, + EditConnection, + RemoveConnection, + ConnectConnection, + DisconnectConnection, + + Query, + Refresh, + SelectAll, + SelectColumns, + EmptyTable, + Rename, + RenameDatabase, + + CreateDatabase, + CreateTable, + CreateView, + CreateProcedure, + CreateConstraint, + CreateUser, + CreateTrigger, + + AlterDatabase, + AlterTable, + AlterView, + AlterProcedure, + AlterConstraint, + AlterUser, + AlterTrigger, + + DropDatabase, + DropTable, + DropView, + DropProcedure, + DropConstraint, + DropUser, + DropTrigger + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/ConnectionManagerPad.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/ConnectionManagerPad.cs new file mode 100644 index 0000000000..21b21920ef --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/ConnectionManagerPad.cs @@ -0,0 +1,53 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.IO; +using MonoDevelop.Core; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +using MonoDevelop.Database.Sql; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class ConnectionManagerPad : TreeViewPad + { + public ConnectionManagerPad () + { + } + + public override void Initialize (NodeBuilder[] builders, TreePadOption[] options) + { + base.Initialize (builders, options); + + Clear (); + LoadTree (ConnectionContextService.DatabaseConnections); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/FakeNodes.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/FakeNodes.cs new file mode 100644 index 0000000000..b7e8c3914c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/FakeNodes.cs @@ -0,0 +1,305 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using MonoDevelop.Database.Sql; + +namespace MonoDevelop.Database.ConnectionManager +{ + public abstract class BaseNode + { + public event EventHandler RefreshEvent; + protected DatabaseConnectionContext context; + + public BaseNode (DatabaseConnectionContext context) + { + if (context == null) + throw new ArgumentNullException ("context"); + + this.context = context; + } + + public DatabaseConnectionContext ConnectionContext { + get { return context; } + } + + public void Refresh () + { + if (RefreshEvent != null) + RefreshEvent (this, EventArgs.Empty); + } + } + + public class TableNode : BaseNode + { + protected TableSchema table; + + public TableNode (DatabaseConnectionContext context, TableSchema table) + : base (context) + { + if (table == null) + throw new ArgumentNullException ("table"); + + this.table = table; + } + + public TableSchema Table { + get { return table; } + } + } + + public class TablesNode : BaseNode + { + public TablesNode (DatabaseConnectionContext context) + : base (context) + { + } + } + + public class ViewNode : BaseNode + { + protected ViewSchema view; + + public ViewNode (DatabaseConnectionContext context, ViewSchema view) + : base (context) + { + if (view == null) + throw new ArgumentNullException ("view"); + + this.view = view; + } + + public ViewSchema View { + get { return view; } + } + } + + public class ViewsNode : BaseNode + { + public ViewsNode (DatabaseConnectionContext context) + : base (context) + { + } + } + + public class ProcedureNode : BaseNode + { + protected ProcedureSchema procedure; + + public ProcedureNode (DatabaseConnectionContext context, ProcedureSchema procedure) + : base (context) + { + if (procedure == null) + throw new ArgumentNullException ("procedure"); + + this.procedure = procedure; + } + + public ProcedureSchema Procedure { + get { return procedure; } + } + } + + public class ProceduresNode : BaseNode + { + public ProceduresNode (DatabaseConnectionContext context) + : base (context) + { + } + } + + public class AggregatesNode : BaseNode + { + public AggregatesNode (DatabaseConnectionContext context) + : base (context) + { + } + } + + public class GroupsNode : BaseNode + { + public GroupsNode (DatabaseConnectionContext context) + : base (context) + { + } + } + + public class LanguagesNode : BaseNode + { + public LanguagesNode (DatabaseConnectionContext context) + : base (context) + { + } + } + + public class OperatorsNode : BaseNode + { + public OperatorsNode (DatabaseConnectionContext context) + : base (context) + { + } + } + + public class RulesNode : BaseNode + { + public RulesNode (DatabaseConnectionContext context) + : base (context) + { + } + } + + public class RolesNode : BaseNode + { + public RolesNode (DatabaseConnectionContext context) + : base (context) + { + } + } + + public class SequencesNode : BaseNode + { + public SequencesNode (DatabaseConnectionContext context) + : base (context) + { + } + } + + public class UserNode : BaseNode + { + protected UserSchema user; + + public UserNode (DatabaseConnectionContext context, UserSchema user) + : base (context) + { + if (user == null) + throw new ArgumentNullException ("user"); + + this.user = user; + } + + public UserSchema User { + get { return user; } + } + } + + public class UsersNode : BaseNode + { + public UsersNode (DatabaseConnectionContext context) + : base (context) + { + } + } + + public class TypesNode : BaseNode + { + public TypesNode (DatabaseConnectionContext context) + : base (context) + { + } + } + + public class ColumnNode : BaseNode + { + protected ColumnSchema column; + + public ColumnNode (DatabaseConnectionContext context, ColumnSchema column) + : base (context) + { + if (column == null) + throw new ArgumentNullException ("column"); + + this.column = column; + } + + public ColumnSchema Column { + get { return column; } + } + } + + public class ColumnsNode : BaseNode + { + protected ISchema schema; + + public ColumnsNode (DatabaseConnectionContext context, ISchema schema) + : base (context) + { + if (schema == null) + throw new ArgumentNullException ("schema"); + + this.schema = schema; + } + + public ISchema Schema { + get { return schema; } + } + } + + public class ConstraintsNode : BaseNode + { + protected ISchema schema; + + public ConstraintsNode (DatabaseConnectionContext context, ISchema schema) + : base (context) + { + if (schema == null) + throw new ArgumentNullException ("schema"); + + this.schema = schema; + } + + public ISchema Schema { + get { return schema; } + } + } + + public class TriggersNode : BaseNode + { + public TriggersNode (DatabaseConnectionContext context) + : base (context) + { + } + } + + public class ParametersNode : BaseNode + { + private ProcedureSchema procedure; + + public ParametersNode (DatabaseConnectionContext context, ProcedureSchema procedure) + : base (context) + { + if (procedure == null) + throw new ArgumentNullException ("procedure"); + + this.procedure = procedure; + } + + public ProcedureSchema Procedure { + get { return procedure; } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/Makefile.am b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/Makefile.am new file mode 100644 index 0000000000..bf9c47fc04 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/Makefile.am @@ -0,0 +1,72 @@ +ADDIN_BUILD = $(top_builddir)/build/AddIns/MonoDevelop.Database +ASSEMBLY = $(ADDIN_BUILD)/MonoDevelop.Database.ConnectionManager.dll +REFS = \ + $(GLIB_SHARP_LIBS) \ + $(GTK_SHARP_LIBS) \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Components.dll \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Designer.dll \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Query.dll \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Sql.dll \ + -r:$(top_builddir)/build/bin/Mono.Addins.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Components.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.Gui.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Ide.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Projects.dll \ + -r:Mono.Posix \ + -r:System \ + -r:System.Data \ + -r:System.Xml + +FILES = \ + ConnectionManagerCommands.cs \ + ConnectionManagerPad.cs \ + FakeNodes.cs \ + NodeBuilders/AggregatesNodeBuilder.cs \ + NodeBuilders/ColumnNodeBuilder.cs \ + NodeBuilders/ColumnsNodeBuilder.cs \ + NodeBuilders/ConnectionContextCollectionNodeBuilder.cs \ + NodeBuilders/ConnectionContextNodeBuilder.cs \ + NodeBuilders/ConstraintNodeBuilder.cs \ + NodeBuilders/ConstraintsNodeBuilder.cs \ + NodeBuilders/GroupsNodeBuilder.cs \ + NodeBuilders/LanguagesNodeBuilder.cs \ + NodeBuilders/OperatorsNodeBuilder.cs \ + NodeBuilders/ParameterNodeBuilder.cs \ + NodeBuilders/ParametersNodeBuilder.cs \ + NodeBuilders/ProcedureNodeBuilder.cs \ + NodeBuilders/ProceduresNodeBuilder.cs \ + NodeBuilders/RolesNodeBuilder.cs \ + NodeBuilders/RulesNodeBuilder.cs \ + NodeBuilders/SequencesNodeBuilder.cs \ + NodeBuilders/TableNodeBuilder.cs \ + NodeBuilders/TablesNodeBuilder.cs \ + NodeBuilders/TriggersNodeBuilder.cs \ + NodeBuilders/TypesNodeBuilder.cs \ + NodeBuilders/UserNodeBuilder.cs \ + NodeBuilders/UsersNodeBuilder.cs \ + NodeBuilders/ViewNodeBuilder.cs \ + NodeBuilders/ViewsNodeBuilder.cs + +RES = MonoDevelop.Database.ConnectionManager.addin.xml + +if ENABLE_DATABASE +all: $(ASSEMBLY) +else
+all:
+endif + +$(ASSEMBLY): $(FILES) $(build_resources) + mkdir -p $(ADDIN_BUILD) + $(CSC) $(CSC_FLAGS) $(REFS) $(build_resources:%=/resource:%) $(build_sources) -out:$@ -target:library + + +if ENABLE_DATABASE +assemblydir = $(MD_ADDIN_DIR)/MonoDevelop.Database +assembly_DATA = $(ASSEMBLY) +endif + +CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb +EXTRA_DIST = $(FILES) $(RES) + +include $(top_srcdir)/Makefile.include diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/MonoDevelop.Database.ConnectionManager.addin.xml b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/MonoDevelop.Database.ConnectionManager.addin.xml new file mode 100644 index 0000000000..ad57caf421 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/MonoDevelop.Database.ConnectionManager.addin.xml @@ -0,0 +1,379 @@ +<Addin id = "Database.ConnectionManager" + namespace = "MonoDevelop" + name = "MonoDevelop Database ConnectionManager" + author = "Christian Hergert, Ben Motmans" + copyright = "MIT X11" + url = "http://www.monodevelop.com" + description = "Database ConnectionManager Module" + version = "0.17.0"> + + <Runtime> + <Import assembly="MonoDevelop.Database.ConnectionManager.dll"/> + </Runtime> + + <Dependencies> + <Addin id="Core" version="0.17.0"/> + <Addin id="Core.Gui" version="0.17.0"/> + <Addin id="Ide" version="0.17.0"/> + <Addin id="Database.Sql" version="0.17.0"/> + <Addin id="Database.Components" version="0.17.0"/> + <Addin id="Database.Query" version="0.17.0"/> + <Addin id="Database.Designer" version="0.17.0"/> + </Dependencies> + + <Extension path = "/MonoDevelop/Ide/Pads"> + <SolutionPad id = "ConnectionManagerPad" class = "MonoDevelop.Database.ConnectionManager.ConnectionManagerPad" defaultPlacement = "Left" _label = "Database Browser" icon = "md-db-database"> + <PadOption id = "ShowSystemObjects" _label = "Show System Objects" defaultValue = "True"/> + <NodeBuilder id = "AggregatesNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.AggregatesNodeBuilder"/> + <NodeBuilder id = "ColumnNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.ColumnNodeBuilder"/> + <NodeBuilder id = "ColumnsNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.ColumnsNodeBuilder"/> + <NodeBuilder id = "ConnectionContextCollectionNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.ConnectionContextCollectionNodeBuilder"/> + <NodeBuilder id = "ConnectionContextNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.ConnectionContextNodeBuilder"/> + <NodeBuilder id = "ConstraintNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.ConstraintNodeBuilder"/> + <NodeBuilder id = "ConstraintsNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.ConstraintsNodeBuilder"/> + <NodeBuilder id = "GroupsNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.GroupsNodeBuilder"/> + <NodeBuilder id = "LanguagesNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.LanguagesNodeBuilder"/> + <NodeBuilder id = "OperatorsNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.OperatorsNodeBuilder"/> + <NodeBuilder id = "ParameterNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.ParameterNodeBuilder"/> + <NodeBuilder id = "ParametersNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.ParametersNodeBuilder"/> + <NodeBuilder id = "ProcedureNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.ProcedureNodeBuilder"/> + <NodeBuilder id = "ProceduresNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.ProceduresNodeBuilder"/> + <NodeBuilder id = "RolesNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.RolesNodeBuilder"/> + <NodeBuilder id = "RulesNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.RulesNodeBuilder"/> + <NodeBuilder id = "SequencesNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.SequencesNodeBuilder"/> + <NodeBuilder id = "TableNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.TableNodeBuilder"/> + <NodeBuilder id = "TablesNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.TablesNodeBuilder"/> + <NodeBuilder id = "TriggersNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.TriggersNodeBuilder"/> + <NodeBuilder id = "TypesNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.TypesNodeBuilder"/> + <NodeBuilder id = "ViewNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.ViewNodeBuilder"/> + <NodeBuilder id = "ViewsNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.ViewsNodeBuilder"/> + <NodeBuilder id = "UserNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.UserNodeBuilder"/> + <NodeBuilder id = "UsersNodeBuilder" class = "MonoDevelop.Database.ConnectionManager.UsersNodeBuilder"/> + </SolutionPad> + </Extension> + + <Extension path = "/MonoDevelop/Ide/WorkbenchContexts/Edit"> + <ContextPad id = "ConnectionManagerPad"/> + </Extension> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/AggregatesNode" name = "Aggregates context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ColumnsNode" name = "Columns context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ColumnNode" name = "Column context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ConnectionsNode" name = "Connections context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ConnectionNode" name = "Connection context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ConstraintNode" name = "Constraint context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ConstraintsNode" name = "Constraints context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/GroupsNode" name = "Groups context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/LanguagesNode" name = "Languages context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/OperatorsNode" name = "Operators context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ParameterNode" name = "Parameter context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ParametersNode" name = "Parameters context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ProcedureNode" name = "Procedure context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ProceduresNode" name = "Procedures context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/RolesNode" name = "Roles context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/RulesNode" name = "Rules context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/SequencesNode" name = "Sequences context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/TableNode" name = "Table context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/TablesNode" name = "Tables context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/TriggerNode" name = "Trigger context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/TriggersNode" name = "Triggers context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/TypesNode" name = "Types context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/UserNode" name = "User context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/UsersNode" name = "Users context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ViewNode" name = "View context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ViewsNode" name = "Views context menu"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <Extension path = "/MonoDevelop/Ide/Commands"> + <Category _name = "Database" id = "Database"> + + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.AddConnection" + _label = "Add Connection" + icon = "gtk-add"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.EditConnection" + _label = "Edit Connection" + icon = "gtk-edit"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.RemoveConnection" + _label = "Remove" + icon = "gtk-remove"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Refresh" + _label = "Refresh" + icon = "gtk-refresh"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.ConnectConnection" + _label = "Connect" + icon = "gtk-connect"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.DisconnectConnection" + _label = "Disconnect" + icon = "gtk-disconnect"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.SelectAll" + _label = "Select *" + icon = "md-db-execute"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.SelectColumns" + _label = "Select x,y,..." + icon = "md-db-execute"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.EmptyTable" + _label = "Empty Table" + icon = "gtk-clear"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Query" + _label = "Query" + icon = "md-db-execute"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Rename" + _label = "Re_name" + shortcut = "F2"/> + <!-- + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.RenameDatabase" + _label = "Rename Database"> + --> + + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.CreateDatabase" + _label = "Create Database" + icon = "gtk-add"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.CreateTable" + _label = "Create Table" + icon = "gtk-add"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.CreateView" + _label = "Create View" + icon = "gtk-add"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.CreateProcedure" + _label = "Create Procedure" + icon = "gtk-add"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.CreateConstraint" + _label = "Create Constraint" + icon = "gtk-add"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.CreateTrigger" + _label = "Create Trigger" + icon = "gtk-add"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.CreateUser" + _label = "Create User" + icon = "gtk-add"/> + + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.AlterDatabase" + _label = "Alter Database" + icon = "gtk-edit"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.AlterTable" + _label = "Alter Table" + icon = "gtk-edit"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.AlterView" + _label = "Alter View" + icon = "gtk-edit"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.AlterProcedure" + _label = "Alter Procedure" + icon = "gtk-edit"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.AlterConstraint" + _label = "Alter Constraint" + icon = "gtk-edit"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.AlterTrigger" + _label = "Alter Trigger" + icon = "gtk-edit"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.AlterUser" + _label = "Alter User" + icon = "gtk-edit"/> + + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.DropDatabase" + _label = "Drop Database" + icon = "gtk-remove"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.DropTable" + _label = "Drop Table" + icon = "gtk-remove"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.DropView" + _label = "Drop View" + icon = "gtk-remove"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.DropProcedure" + _label = "Drop Procedure" + icon = "gtk-remove"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.DropTrigger" + _label = "Drop Trigger" + icon = "gtk-remove"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.DropConstraint" + _label = "Drop Constraint" + icon = "gtk-remove"/> + <Command id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.DropUser" + _label = "Drop User" + icon = "gtk-remove"/> + </Category> + </Extension> + + <Extension path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ConnectionsNode"> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.AddConnection"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.CreateDatabase"/> + </Extension> + + <Extension path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ConnectionNode"> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.ConnectConnection"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.DisconnectConnection"/> + <SeparatorItem id = "DisconnectSeparator"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Rename"/> + <!--<CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.RenameDatabase"/>--> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.EditConnection"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.RemoveConnection"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.DropDatabase"/> + <SeparatorItem id = "RefreshSeparator" /> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Refresh"/> + </Extension> + + <Extension path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/TablesNode"> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.CreateTable"/> + <SeparatorItem id = "RefreshSeparator" /> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Refresh"/> + </Extension> + + <Extension path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ViewsNode"> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.CreateView"/> + <SeparatorItem id = "RefreshSeparator" /> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Refresh"/> + </Extension> + + <Extension path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ProceduresNode"> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.CreateProcedure"/> + <SeparatorItem id = "RefreshSeparator" /> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Refresh"/> + </Extension> + + <Extension path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/UsersNode"> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.CreateUser"/> + <SeparatorItem id = "RefreshSeparator" /> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Refresh"/> + </Extension> + + <Extension path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ConstraintsNode"> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.CreateConstraint"/> + <SeparatorItem id = "RefreshSeparator" /> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Refresh"/> + </Extension> + + <Extension path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/TriggersNode"> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.CreateTrigger"/> + <SeparatorItem id = "RefreshSeparator" /> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Refresh"/> + </Extension> + + <Extension path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/TableNode"> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.SelectAll"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.SelectColumns"/> + <SeparatorItem id = "SelectSeparator" /> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Rename"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.AlterTable"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.EmptyTable"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.DropTable"/> + <SeparatorItem id = "RefreshSeparator" /> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Refresh"/> + </Extension> + + <Extension path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ViewNode"> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.SelectAll"/> + <SeparatorItem id = "SelectSeparator" /> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Rename"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.AlterView"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.DropView"/> + <SeparatorItem id = "RefreshSeparator" /> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Refresh"/> + </Extension> + + <Extension path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ProcedureNode"> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Rename"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.AlterProcedure"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.DropProcedure"/> + <SeparatorItem id = "RefreshSeparator" /> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Refresh"/> + </Extension> + + <Extension path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/UserNode"> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Rename"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.AlterUser"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.DropUser"/> + <SeparatorItem id = "RefreshSeparator" /> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Refresh"/> + </Extension> + + <Extension path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/TriggerNode"> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Rename"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.AlterTrigger"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.DropTrigger"/> + <SeparatorItem id = "RefreshSeparator" /> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Refresh"/> + </Extension> + + <Extension path = "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ConstraintNode"> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Rename"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.AlterConstraint"/> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.DropConstraint"/> + <SeparatorItem id = "RefreshSeparator" /> + <CommandItem id = "MonoDevelop.Database.ConnectionManager.ConnectionManagerCommands.Refresh"/> + </Extension> +</Addin> diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/MonoDevelop.Database.ConnectionManager.mdp b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/MonoDevelop.Database.ConnectionManager.mdp new file mode 100644 index 0000000000..1ed36ad58d --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/MonoDevelop.Database.ConnectionManager.mdp @@ -0,0 +1,78 @@ +<Project name="MonoDevelop.Database.ConnectionManager" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.ConnectionManager" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.ConnectionManager" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="ConnectionManagerPad.cs" subtype="Code" buildaction="Compile" /> + <File name="MonoDevelop.Database.ConnectionManager.addin.xml" subtype="Code" buildaction="EmbedAsResource" /> + <File name="NodeBuilders/ConnectionContextCollectionNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/ConnectionContextNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/TablesNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/ViewsNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/ProceduresNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/UsersNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/ConstraintsNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="FakeNodes.cs" subtype="Code" buildaction="Compile" /> + <File name="ConnectionManagerCommands.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/TableNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/UserNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/ProcedureNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/ViewNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/ColumnNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/ColumnsNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/ConstraintNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/AggregatesNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/GroupsNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/LanguagesNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/OperatorsNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/RolesNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/RulesNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/SequencesNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/TriggersNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/TypesNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/ParametersNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="NodeBuilders/ParameterNodeBuilder.cs" subtype="Code" buildaction="Compile" /> + <File name="Makefile.am" subtype="Code" buildaction="Nothing" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" /> + <ProjectReference type="Gac" localcopy="True" refto="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Components" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Designer" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Sql" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Query" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core.Gui" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Components" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Ide" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Projects" /> + <ProjectReference type="Project" localcopy="False" refto="Mono.Addins" /> + <ProjectReference type="Gac" localcopy="True" refto="glib-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="pango-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="atk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + </References> + <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am" BuildTargetName="" CleanTargetName="" SyncReferences="True" IsAutotoolsProject="True" RelativeConfigureInPath="../../../"> + <BuildFilesVar Sync="True" Name="FILES" /> + <DeployFilesVar /> + <ResourcesVar Sync="True" Name="RES" /> + <OthersVar /> + <GacRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <AsmRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <ProjectRefVar Sync="True" Name="REFS" Prefix="-r:" /> + </MonoDevelop.Autotools.MakefileInfo> +</Project>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/AggregatesNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/AggregatesNodeBuilder.cs new file mode 100644 index 0000000000..8528cb0dbe --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/AggregatesNodeBuilder.cs @@ -0,0 +1,116 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class AggregatesNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public AggregatesNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (AggregatesNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/AggregatesNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (AggregatesNodeCommandHandler); } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Aggregates"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + label = GettextCatalog.GetString ("Aggregates"); + icon = Context.GetIcon ("md-db-tables"); + + BaseNode node = (BaseNode) dataObject; + node.RefreshEvent += RefreshHandler; + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + //TODO: + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return false; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (); + + if (builder != null) + builder.UpdateChildren (); + + builder.ExpandToNode (); + } + } + + public class AggregatesNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ColumnNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ColumnNodeBuilder.cs new file mode 100644 index 0000000000..6281595f44 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ColumnNodeBuilder.cs @@ -0,0 +1,96 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class ColumnNodeBuilder : TypeNodeBuilder + { + public ColumnNodeBuilder () + : base () + { + } + + public override Type NodeDataType { + get { return typeof (ColumnSchema); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ColumnNode"; } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Column"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + ColumnSchema column = dataObject as ColumnSchema; + + label = column.Name + " (" + column.DataType.Name + ")"; + icon = Context.GetIcon ("md-db-column"); + //TODO: icon based on column type + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + ColumnNode node = state as ColumnNode; + ITreeBuilder builder = Context.GetTreeBuilder (state); + IDbFactory fac = node.ConnectionContext.DbFactory; + + if (fac.IsCapabilitySupported ("TableColumn", SchemaActions.Schema, ColumnCapabilities.PrimaryKeyConstraint) + || fac.IsCapabilitySupported ("TableColumn", SchemaActions.Schema, ColumnCapabilities.ForeignKeyConstraint) + || fac.IsCapabilitySupported ("TableColumn", SchemaActions.Schema, ColumnCapabilities.CheckConstraint) + || fac.IsCapabilitySupported ("TableColumn", SchemaActions.Schema, ColumnCapabilities.UniqueConstraint) + ) + DispatchService.GuiDispatch (delegate { + builder.AddChild (new ConstraintsNode (node.ConnectionContext, node.Column)); + builder.Expanded = true; + }); + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return true; + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ColumnsNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ColumnsNodeBuilder.cs new file mode 100644 index 0000000000..452cf3175d --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ColumnsNodeBuilder.cs @@ -0,0 +1,136 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class ColumnsNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public ColumnsNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (ColumnsNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ColumnsNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (ColumnsNodeCommandHandler); } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Columns"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + label = GettextCatalog.GetString ("Columns"); + icon = Context.GetIcon ("md-db-tables"); + + BaseNode node = (BaseNode) dataObject; + node.RefreshEvent += RefreshHandler; + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + ColumnsNode node = state as ColumnsNode; + ITreeBuilder builder = Context.GetTreeBuilder (state); + ISchema schema = node.Schema; + + ColumnSchemaCollection columns = null; + if (schema is TableSchema) + columns = node.ConnectionContext.SchemaProvider.GetTableColumns (schema as TableSchema); + else if (schema is ViewSchema) + columns = node.ConnectionContext.SchemaProvider.GetViewColumns (schema as ViewSchema); + + if (columns == null) + return; + + foreach (ColumnSchema column in columns) { + DispatchService.GuiDispatch (delegate { + builder.AddChild (column); + }); + } + DispatchService.GuiDispatch (delegate { + builder.Expanded = true; + }); + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return true; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (); + + if (builder != null) + builder.UpdateChildren (); + + builder.ExpandToNode (); + } + } + + public class ColumnsNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ConnectionContextCollectionNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ConnectionContextCollectionNodeBuilder.cs new file mode 100644 index 0000000000..471e80cfe3 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ConnectionContextCollectionNodeBuilder.cs @@ -0,0 +1,164 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Gtk; +using System; +using System.Threading; +using MonoDevelop.Core; +using MonoDevelop.Components.Commands; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Designer; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class ConnectionContextCollectionNodeBuilder : TypeNodeBuilder + { + private ITreeBuilder builder; + + public ConnectionContextCollectionNodeBuilder () + : base () + { + ConnectionContextService.ConnectionContextAdded += (DatabaseConnectionContextEventHandler)DispatchService.GuiDispatch (new DatabaseConnectionContextEventHandler (OnConnectionAdded)); + ConnectionContextService.ConnectionContextRemoved += (DatabaseConnectionContextEventHandler)DispatchService.GuiDispatch (new DatabaseConnectionContextEventHandler (OnConnectionRemoved)); + } + + public override Type NodeDataType { + get { return typeof (DatabaseConnectionContextCollection); } + } + + public override Type CommandHandlerType { + get { return typeof (ConnectionContextCollectionCommandHandler); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ConnectionsNode"; } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Database Connections"); + } + + public override void BuildNode (ITreeBuilder builder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + label = GettextCatalog.GetString ("Database Connections"); + icon = Context.GetIcon ("md-db-connection"); + this.builder = builder; + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + DatabaseConnectionContextCollection collection = (DatabaseConnectionContextCollection) dataObject; + LoggingService.LogDebug ("BuildChildNodes CONTEXT " + collection.Count); + + foreach (DatabaseConnectionContext context in collection) + builder.AddChild (context); + builder.Expanded = true; + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + LoggingService.LogDebug ("HasChildNodes CONTEXT"); + DatabaseConnectionContextCollection collection = (DatabaseConnectionContextCollection) dataObject; + return collection.Count > 0; + } + + private void OnConnectionAdded (object sender, DatabaseConnectionContextEventArgs args) + { + builder.AddChild (args.ConnectionContext); + } + + private void OnConnectionRemoved (object sender, DatabaseConnectionContextEventArgs args) + { + if (builder.MoveToObject (args.ConnectionContext)) { + builder.Remove (); + builder.MoveToParent (); + } + } + } + + public class ConnectionContextCollectionCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + [CommandHandler (ConnectionManagerCommands.CreateDatabase)] + protected void OnCreateDatabase () + { + CreateDatabaseDialog dlg = new CreateDatabaseDialog (); + if (dlg.Run () == (int)ResponseType.Ok) { + DatabaseConnectionContext context = dlg.DatabaseConnection; + WaitDialog.ShowDialog ("Creating database ..."); + ThreadPool.QueueUserWorkItem (new WaitCallback (OnCreateDatabaseThreaded), context); + } + dlg.Destroy (); + } + + [CommandUpdateHandler (ConnectionManagerCommands.CreateDatabase)] + protected void OnUpdateCreateDatabase (CommandInfo info) + { + info.Enabled = DbFactoryService.DbFactoryCount > 0; + } + + [CommandHandler (ConnectionManagerCommands.AddConnection)] + protected void OnAddConnection () + { + DatabaseConnectionSettingsDialog dlg = new DatabaseConnectionSettingsDialog (); + if (dlg.Run () == (int)ResponseType.Ok) + ConnectionContextService.AddDatabaseConnectionContext (dlg.ConnectionSettings); + dlg.Destroy (); + } + + [CommandUpdateHandler (ConnectionManagerCommands.AddConnection)] + protected void OnUpdateAddConnection (CommandInfo info) + { + info.Enabled = DbFactoryService.DbFactoryCount > 0; + } + + private void OnCreateDatabaseThreaded (object state) + { + DatabaseConnectionContext context = state as DatabaseConnectionContext; + + ISchemaProvider schemaProvider = context.SchemaProvider; + DatabaseSchema db = new DatabaseSchema (schemaProvider); + db.Name = context.ConnectionSettings.Database; + + schemaProvider.CreateDatabase (db); + + DispatchService.GuiDispatch (delegate () { + WaitDialog.HideDialog (); + ConnectionContextService.AddDatabaseConnectionContext (context); + }); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ConnectionContextNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ConnectionContextNodeBuilder.cs new file mode 100644 index 0000000000..2ab6f4b030 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ConnectionContextNodeBuilder.cs @@ -0,0 +1,291 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Gtk; +using System; +using System.Threading; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Database.Query; +using MonoDevelop.Database.Components; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class ConnectionContextNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public ConnectionContextNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (DatabaseConnectionContext); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ConnectionNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (ConnectionContextCommandHandler); } + } + + public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes) + { + attributes |= NodeAttributes.AllowRename; + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + DatabaseConnectionContext context = dataObject as DatabaseConnectionContext; + return context.ConnectionSettings.Name; + } + + public override void BuildNode (ITreeBuilder builder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + DatabaseConnectionContext context = dataObject as DatabaseConnectionContext; + context.RefreshEvent += (EventHandler)DispatchService.GuiDispatch (RefreshHandler); + + label = context.ConnectionSettings.Name; + if (context.HasConnectionPool) { + IConnectionPool pool = context.ConnectionPool; + if (pool.IsInitialized) { + icon = Context.GetIcon ("md-db-database-ok"); + } else if (pool.HasErrors) { + icon = Context.GetIcon ("md-db-database-error"); + Services.MessageService.ShowError (GettextCatalog.GetString ("Unable to connect:") + Environment.NewLine + pool.Error); + } else { + icon = Context.GetIcon ("md-db-database"); + } + } else { + icon = Context.GetIcon ("md-db-database"); + } + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + QueryService.EnsureConnection (state as DatabaseConnectionContext, new DatabaseConnectionContextCallback (BuildChildNodesGui), state); + } + + private void BuildChildNodesGui (DatabaseConnectionContext context, bool connected, object state) + { + ITreeBuilder builder = Context.GetTreeBuilder (state); + + builder.Update (); + if (connected) { + IDbFactory fac = context.DbFactory; + + if (fac.IsActionSupported ("Table", SchemaActions.Schema)) + builder.AddChild (new TablesNode (context)); + + if (fac.IsActionSupported ("View", SchemaActions.Schema)) + builder.AddChild (new ViewsNode (context)); + + if (fac.IsActionSupported ("Procedure", SchemaActions.Schema)) + builder.AddChild (new ProceduresNode (context)); + + if (fac.IsActionSupported ("User", SchemaActions.Schema)) + builder.AddChild (new UsersNode (context)); + + //TODO: custom datatypes, sequences, roles, operators, languages, groups and aggregates + + builder.Expanded = true; + } + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return true; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (sender); + builder.Update (); + } + } + + public class ConnectionContextCommandHandler : NodeCommandHandler + { + public override void RenameItem (string newName) + { + DatabaseConnectionContext context = (DatabaseConnectionContext) CurrentNode.DataItem; + if (context.ConnectionSettings.Name != newName) { + if (ConnectionContextService.DatabaseConnections.Contains (newName)) { + Services.MessageService.ShowError (String.Format ( + "Unable to rename connection '{0}' to '{1}'! (duplicate name)", + context.ConnectionSettings.Name, newName + )); + } else { + context.ConnectionSettings.Name = newName; + OnRefreshConnection (); + } + } + } + + [CommandHandler (ConnectionManagerCommands.RemoveConnection)] + protected void OnRemoveConnection () + { + DatabaseConnectionContext context = (DatabaseConnectionContext) CurrentNode.DataItem; + if (Services.MessageService.AskQuestion ( + GettextCatalog.GetString ("Are you sure you want to remove connection '{0}'?", context.ConnectionSettings.Name), + GettextCatalog.GetString ("Remove Connection"))) { + ConnectionContextService.RemoveDatabaseConnectionContext (context); + } + } + + [CommandHandler (ConnectionManagerCommands.EditConnection)] + protected void OnEditConnection () + { + DatabaseConnectionContext context = (DatabaseConnectionContext) CurrentNode.DataItem; + DatabaseConnectionSettingsDialog dlg = new DatabaseConnectionSettingsDialog (context.ConnectionSettings); + + if (dlg.Run () == (int)ResponseType.Ok) { + ConnectionContextService.EditDatabaseConnectionContext (context); + OnRefreshConnection (); + } + dlg.Destroy (); + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefreshConnection () + { + DatabaseConnectionContext context = (DatabaseConnectionContext) CurrentNode.DataItem; + context.Refresh (); + } + + [CommandHandler (ConnectionManagerCommands.DisconnectConnection)] + protected void OnDisconnectConnection () + { + DatabaseConnectionContext context = (DatabaseConnectionContext) CurrentNode.DataItem; + if (context.HasConnectionPool) { + context.ConnectionPool.Close (); + context.Refresh (); + CurrentNode.Expanded = false; + } + } + + [CommandUpdateHandler (ConnectionManagerCommands.DisconnectConnection)] + protected void OnUpdateDisconnectConnection (CommandInfo info) + { + DatabaseConnectionContext context = (DatabaseConnectionContext) CurrentNode.DataItem; + info.Enabled = context.HasConnectionPool && context.ConnectionPool.IsInitialized; + } + + [CommandHandler (ConnectionManagerCommands.ConnectConnection)] + protected void OnConnectConnection () + { + CurrentNode.Expanded = true; + } + + [CommandUpdateHandler (ConnectionManagerCommands.ConnectConnection)] + protected void OnUpdateConnectConnection (CommandInfo info) + { + DatabaseConnectionContext context = (DatabaseConnectionContext) CurrentNode.DataItem; + if (context.HasConnectionPool) + info.Enabled = !context.ConnectionPool.IsInitialized; + else + info.Enabled = true; + } + + public override void ActivateItem () + { + OnQueryCommand (); + } + + [CommandHandler (ConnectionManagerCommands.Query)] + protected void OnQueryCommand () + { + SqlQueryView view = new SqlQueryView (); + view.SelectedConnectionContext = (DatabaseConnectionContext) CurrentNode.DataItem; + + IdeApp.Workbench.OpenDocument (view, true); + } + + [CommandHandler (ConnectionManagerCommands.DropDatabase)] + protected void OnDropDatabase () + { + DatabaseConnectionContext context = (DatabaseConnectionContext) CurrentNode.DataItem; + if (Services.MessageService.AskQuestion ( + GettextCatalog.GetString ("Are you sure you want to drop database '{0}'", context.ConnectionSettings.Database), + GettextCatalog.GetString ("Drop Database") + )) { + ThreadPool.QueueUserWorkItem (new WaitCallback (OnDropDatabaseThreaded), CurrentNode.DataItem); + } + } + + private void OnDropDatabaseThreaded (object state) + { + DatabaseConnectionContext context = (DatabaseConnectionContext) CurrentNode.DataItem; + ISchemaProvider provider = context.SchemaProvider; + DatabaseSchema db = provider.GetNewDatabaseSchema (context.ConnectionSettings.Name); + + context.SchemaProvider.DropDatabase (db); + DispatchService.GuiDispatch (delegate () { OnRefreshConnection (); }); + } + + [CommandUpdateHandler (ConnectionManagerCommands.DropDatabase)] + protected void OnUpdateDropDatabase (CommandInfo info) + { + DatabaseConnectionContext context = (DatabaseConnectionContext) CurrentNode.DataItem; + info.Enabled = context.DbFactory.IsActionSupported ("Database", SchemaActions.Drop); + } + + [CommandUpdateHandler (ConnectionManagerCommands.AlterDatabase)] + protected void OnUpdateAlterDatabase (CommandInfo info) + { + DatabaseConnectionContext context = (DatabaseConnectionContext) CurrentNode.DataItem; + info.Enabled = context.DbFactory.IsActionSupported ("Database", SchemaActions.Alter); + } + + [CommandHandler (ConnectionManagerCommands.RenameDatabase)] + protected void OnRenameDatabase () + { + //TODO: show a dialog, since inline tree renaming for this node renames the custom name + } + + [CommandUpdateHandler (ConnectionManagerCommands.RenameDatabase)] + protected void OnUpdateRenameDatabase (CommandInfo info) + { + DatabaseConnectionContext context = (DatabaseConnectionContext) CurrentNode.DataItem; + info.Enabled = context.DbFactory.IsActionSupported ("Database", SchemaActions.Rename); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ConstraintNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ConstraintNodeBuilder.cs new file mode 100644 index 0000000000..dbfba96536 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ConstraintNodeBuilder.cs @@ -0,0 +1,78 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class ConstraintNodeBuilder : TypeNodeBuilder + { + public ConstraintNodeBuilder () + : base () + { + } + + public override Type NodeDataType { + get { return typeof (ConstraintSchema); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ConstraintNode"; } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Constraint"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + ConstraintSchema constraint = dataObject as ConstraintSchema; + + label = constraint.Name; + icon = Context.GetIcon ("md-db-constraint"); + //TODO: icon based on constraint type + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return false; + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ConstraintsNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ConstraintsNodeBuilder.cs new file mode 100644 index 0000000000..36bd3eb225 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ConstraintsNodeBuilder.cs @@ -0,0 +1,133 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class ConstraintsNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public ConstraintsNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (ConstraintsNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ConstraintsNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (ConstraintsNodeCommandHandler); } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Constraints"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + label = GettextCatalog.GetString ("Constraints"); + icon = Context.GetIcon ("md-db-tables"); + + BaseNode node = (BaseNode) dataObject; + node.RefreshEvent += (EventHandler)(DispatchService.GuiDispatch (RefreshHandler)); + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + ConstraintsNode node = state as ConstraintsNode; + ITreeBuilder builder = Context.GetTreeBuilder (state); + + ConstraintSchemaCollection constraints = null; + if (node.Schema is TableSchema) { + constraints = (node.Schema as TableSchema).Constraints; + } else if (node.Schema is ColumnSchema) { + constraints = (node.Schema as ColumnSchema).Constraints; + } + + if (constraints == null) + return; + + DispatchService.GuiDispatch (delegate { + foreach (ConstraintSchema constraint in constraints) + builder.AddChild (constraint); + builder.Expanded = true; + }); + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return true; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (); + + if (builder != null) + builder.UpdateChildren (); + + builder.ExpandToNode (); + } + } + + public class ConstraintsNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/GroupsNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/GroupsNodeBuilder.cs new file mode 100644 index 0000000000..0160f1d233 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/GroupsNodeBuilder.cs @@ -0,0 +1,116 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class GroupsNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public GroupsNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (GroupsNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/GroupsNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (GroupsNodeCommandHandler); } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Groups"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + label = GettextCatalog.GetString ("Groups"); + icon = Context.GetIcon ("md-db-tables"); + + BaseNode node = (BaseNode) dataObject; + node.RefreshEvent += RefreshHandler; + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + //TODO: + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return false; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (); + + if (builder != null) + builder.UpdateChildren (); + + builder.ExpandToNode (); + } + } + + public class GroupsNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/LanguagesNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/LanguagesNodeBuilder.cs new file mode 100644 index 0000000000..c5edc5eac6 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/LanguagesNodeBuilder.cs @@ -0,0 +1,116 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class LanguagesNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public LanguagesNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (LanguagesNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/LanguagesNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (LanguagesNodeCommandHandler); } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Languages"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + label = GettextCatalog.GetString ("Languages"); + icon = Context.GetIcon ("md-db-tables"); + + BaseNode node = (BaseNode) dataObject; + node.RefreshEvent += RefreshHandler; + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + //TODO: + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return false; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (); + + if (builder != null) + builder.UpdateChildren (); + + builder.ExpandToNode (); + } + } + + public class LanguagesNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/OperatorsNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/OperatorsNodeBuilder.cs new file mode 100644 index 0000000000..37720e4ad7 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/OperatorsNodeBuilder.cs @@ -0,0 +1,116 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class OperatorsNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public OperatorsNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (OperatorsNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/OperatorsNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (OperatorsNodeCommandHandler); } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Operators"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + label = GettextCatalog.GetString ("Operators"); + icon = Context.GetIcon ("md-db-tables"); + + BaseNode node = (BaseNode) dataObject; + node.RefreshEvent += RefreshHandler; + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + //TODO: + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return false; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (); + + if (builder != null) + builder.UpdateChildren (); + + builder.ExpandToNode (); + } + } + + public class OperatorsNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ParameterNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ParameterNodeBuilder.cs new file mode 100644 index 0000000000..9e9ce11165 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ParameterNodeBuilder.cs @@ -0,0 +1,78 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class ParameterNodeBuilder : TypeNodeBuilder + { + public ParameterNodeBuilder () + : base () + { + } + + public override Type NodeDataType { + get { return typeof (ParameterSchema); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ParameterNode"; } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Parameter"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + ParameterSchema parameter = dataObject as ParameterSchema; + + label = parameter.Name + " (" + parameter.ParameterType.ToString () + ")"; + icon = Context.GetIcon ("md-db-column"); + //TODO: icon based on column type + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return false; + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ParametersNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ParametersNodeBuilder.cs new file mode 100644 index 0000000000..c9f50553e6 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ParametersNodeBuilder.cs @@ -0,0 +1,126 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class ParametersNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public ParametersNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (ParametersNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ParametersNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (ParametersNodeCommandHandler); } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Parameters"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + label = GettextCatalog.GetString ("Parameters"); + icon = Context.GetIcon ("md-db-tables"); + + BaseNode node = (BaseNode) dataObject; + node.RefreshEvent += RefreshHandler; + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + ParametersNode node = state as ParametersNode; + ITreeBuilder builder = Context.GetTreeBuilder (state); + + ParameterSchemaCollection parameters = node.ConnectionContext.SchemaProvider.GetProcedureParameters (node.Procedure); + + foreach (ParameterSchema parameter in parameters) { + DispatchService.GuiDispatch (delegate { + builder.AddChild (parameter); + builder.Expanded = true; + }); + } + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return true; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (); + + if (builder != null) + builder.UpdateChildren (); + + builder.ExpandToNode (); + } + } + + public class ParametersNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ProcedureNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ProcedureNodeBuilder.cs new file mode 100644 index 0000000000..0b3faba84f --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ProcedureNodeBuilder.cs @@ -0,0 +1,233 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class ProcedureNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public ProcedureNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (ProcedureNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ProcedureNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (ProcedureNodeCommandHandler); } + } + + public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes) + { + attributes |= NodeAttributes.AllowRename; + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + ProcedureNode node = dataObject as ProcedureNode; + return node.Procedure.Name; + } + + public override void BuildNode (ITreeBuilder builder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + ProcedureNode node = dataObject as ProcedureNode; + node.RefreshEvent += (EventHandler)DispatchService.GuiDispatch (RefreshHandler); + + label = node.Procedure.Name; + icon = Context.GetIcon ("md-db-procedure"); + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + ProcedureNode node = state as ProcedureNode; + ITreeBuilder builder = Context.GetTreeBuilder (state); + IDbFactory fac = node.ConnectionContext.DbFactory; + + if (fac.IsCapabilitySupported ("Procedure", SchemaActions.Schema, ProcedureCapabilities.Parameters)) { + DispatchService.GuiDispatch (delegate { + builder.AddChild (new ParametersNode (node.ConnectionContext, node.Procedure)); + builder.Expanded = true; + }); + } + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + ProcedureNode node = dataObject as ProcedureNode; + IDbFactory fac = node.ConnectionContext.DbFactory; + return fac.IsCapabilitySupported ("Procedure", SchemaActions.Schema, ProcedureCapabilities.Parameters); + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (sender); + builder.Update (); + } + } + + public class ProcedureNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + public override void RenameItem (string newName) + { + ProcedureNode node = (ProcedureNode)CurrentNode.DataItem; + if (node.Procedure.Name != newName) + ThreadPool.QueueUserWorkItem (new WaitCallback (RenameItemThreaded), new object[]{ node, newName }); + } + + private void RenameItemThreaded (object state) + { + object[] objs = state as object[]; + + ProcedureNode node = objs[0] as ProcedureNode; + string newName = objs[1] as string; + ISchemaProvider provider = node.Procedure.SchemaProvider; + + if (provider.IsValidName (newName)) { + provider.RenameProcedure (node.Procedure, newName); + node.Refresh (); + } else { + DispatchService.GuiDispatch (delegate () { + Services.MessageService.ShowError (String.Format ( + "Unable to rename procedure '{0}' to '{1}'!", + node.Procedure.Name, newName + )); + }); + } + node.Refresh (); + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + + protected void OnRefreshParent () + { + if (CurrentNode.MoveToParent ()) { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + } + + [CommandHandler (ConnectionManagerCommands.AlterProcedure)] + protected void OnAlterProcedure () + { + ProcedureNode node = CurrentNode.DataItem as ProcedureNode; + IDbFactory fac = node.ConnectionContext.DbFactory; + ISchemaProvider schemaProvider = node.ConnectionContext.SchemaProvider; + + if (fac.GuiProvider.ShowProcedureEditorDialog (schemaProvider, node.Procedure, false)) + ThreadPool.QueueUserWorkItem (new WaitCallback (OnAlterProcedureThreaded), CurrentNode.DataItem); + } + + private void OnAlterProcedureThreaded (object state) + { + ProcedureNode node = (ProcedureNode)state; + ISchemaProvider provider = node.ConnectionContext.SchemaProvider; + + provider.AlterProcedure (node.Procedure); + } + + [CommandHandler (ConnectionManagerCommands.DropProcedure)] + protected void OnDropProcedure () + { + ProcedureNode node = (ProcedureNode)CurrentNode.DataItem; + if (Services.MessageService.AskQuestion ( + GettextCatalog.GetString ("Are you sure you want to drop procedure '{0}'", node.Procedure.Name), + GettextCatalog.GetString ("Drop Procedure") + )) { + ThreadPool.QueueUserWorkItem (new WaitCallback (OnDropProcedureThreaded), CurrentNode.DataItem); + } + } + + private void OnDropProcedureThreaded (object state) + { + ProcedureNode node = (ProcedureNode)state; + ISchemaProvider provider = node.ConnectionContext.SchemaProvider; + + provider.DropProcedure (node.Procedure); + OnRefreshParent (); + } + + [CommandHandler (ConnectionManagerCommands.Rename)] + protected void OnRenameProcedure () + { + Tree.StartLabelEdit (); + } + + [CommandUpdateHandler (ConnectionManagerCommands.DropProcedure)] + protected void OnUpdateDropProcedure (CommandInfo info) + { + BaseNode node = (BaseNode)CurrentNode.DataItem; + info.Enabled = node.ConnectionContext.DbFactory.IsActionSupported ("Procedure", SchemaActions.Drop); + } + + [CommandUpdateHandler (ConnectionManagerCommands.Rename)] + protected void OnUpdateRenameProcedure (CommandInfo info) + { + BaseNode node = (BaseNode)CurrentNode.DataItem; + info.Enabled = node.ConnectionContext.DbFactory.IsActionSupported ("Procedure", SchemaActions.Rename); + } + + [CommandUpdateHandler (ConnectionManagerCommands.AlterProcedure)] + protected void OnUpdateAlterProcedure (CommandInfo info) + { + BaseNode node = (BaseNode)CurrentNode.DataItem; + info.Enabled = node.ConnectionContext.DbFactory.IsActionSupported ("Procedure", SchemaActions.Alter); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ProceduresNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ProceduresNodeBuilder.cs new file mode 100644 index 0000000000..5f7dc00d1b --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ProceduresNodeBuilder.cs @@ -0,0 +1,160 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Gtk; +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Designer; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class ProceduresNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public ProceduresNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (ProceduresNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ProceduresNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (ProceduresNodeCommandHandler); } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Procedures"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + label = GettextCatalog.GetString ("Procedures"); + icon = Context.GetIcon ("md-db-procedure"); + + BaseNode node = (BaseNode) dataObject; + node.RefreshEvent += (EventHandler)(DispatchService.GuiDispatch (RefreshHandler)); + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + BaseNode node = state as BaseNode; + ITreeBuilder builder = Context.GetTreeBuilder (state); + + bool showSystemObjects = (bool)builder.Options["ShowSystemObjects"]; + ProcedureSchemaCollection procedures = node.ConnectionContext.SchemaProvider.GetProcedures (); + DispatchService.GuiDispatch (delegate { + foreach (ProcedureSchema procedure in procedures) { + if (procedure.IsSystemProcedure && !showSystemObjects) + continue; + + builder.AddChild (new ProcedureNode (node.ConnectionContext, procedure)); + } + builder.Expanded = true; + }); + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return true; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (); + + builder.UpdateChildren (); + builder.ExpandToNode (); + } + } + + public class ProceduresNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + + [CommandHandler (ConnectionManagerCommands.CreateProcedure)] + protected void OnCreateProcedure () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + IDbFactory fac = node.ConnectionContext.DbFactory; + ISchemaProvider schemaProvider = node.ConnectionContext.SchemaProvider; + ProcedureSchema proc = schemaProvider.GetNewProcedureSchema ("NewProcedure"); + + if (fac.GuiProvider.ShowProcedureEditorDialog (schemaProvider, proc, true)) + ThreadPool.QueueUserWorkItem (new WaitCallback (OnCreateProcedureThreaded), new object[] {schemaProvider, proc, node} as object); + } + + private void OnCreateProcedureThreaded (object state) + { + object[] objs = state as object[]; + + ISchemaProvider provider = objs[0] as ISchemaProvider; + ProcedureSchema proc = objs[1] as ProcedureSchema; + BaseNode node = objs[2] as BaseNode; + + provider.CreateProcedure (proc); + node.Refresh (); + } + + [CommandUpdateHandler (ConnectionManagerCommands.CreateProcedure)] + protected void OnUpdateCreateProcedure (CommandInfo info) + { + BaseNode node = (BaseNode)CurrentNode.DataItem; + info.Enabled = node.ConnectionContext.DbFactory.IsActionSupported ("Procedure", SchemaActions.Create); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/RolesNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/RolesNodeBuilder.cs new file mode 100644 index 0000000000..d42e441898 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/RolesNodeBuilder.cs @@ -0,0 +1,116 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class RolesNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public RolesNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (RolesNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/RolesNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (RolesNodeCommandHandler); } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Roles"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + label = GettextCatalog.GetString ("Roles"); + icon = Context.GetIcon ("md-db-tables"); + + BaseNode node = (BaseNode) dataObject; + node.RefreshEvent += RefreshHandler; + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + //TODO: + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return false; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (); + + if (builder != null) + builder.UpdateChildren (); + + builder.ExpandToNode (); + } + } + + public class RolesNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/RulesNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/RulesNodeBuilder.cs new file mode 100644 index 0000000000..cbc9c8c211 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/RulesNodeBuilder.cs @@ -0,0 +1,116 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class RulesNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public RulesNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (RulesNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/RulesNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (RulesNodeCommandHandler); } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Rules"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + label = GettextCatalog.GetString ("Rules"); + icon = Context.GetIcon ("md-db-tables"); + + BaseNode node = (BaseNode) dataObject; + node.RefreshEvent += RefreshHandler; + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + //TODO: + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return false; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (); + + if (builder != null) + builder.UpdateChildren (); + + builder.ExpandToNode (); + } + } + + public class RulesNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/SequencesNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/SequencesNodeBuilder.cs new file mode 100644 index 0000000000..adeaca55ea --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/SequencesNodeBuilder.cs @@ -0,0 +1,116 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class SequencesNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public SequencesNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (SequencesNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/SequencesNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (SequencesNodeCommandHandler); } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Sequences"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + label = GettextCatalog.GetString ("Sequences"); + icon = Context.GetIcon ("md-db-tables"); + + BaseNode node = (BaseNode) dataObject; + node.RefreshEvent += RefreshHandler; + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + //TODO: + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return false; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (); + + if (builder != null) + builder.UpdateChildren (); + + builder.ExpandToNode (); + } + } + + public class SequencesNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/TableNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/TableNodeBuilder.cs new file mode 100644 index 0000000000..3808cc57f5 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/TableNodeBuilder.cs @@ -0,0 +1,358 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Gtk; +using System; +using System.Data; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Database.Query; +using MonoDevelop.Database.Components; +using MonoDevelop.Database.Designer; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class TableNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public TableNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (TableNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/TableNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (TableNodeCommandHandler); } + } + + public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes) + { + attributes |= NodeAttributes.AllowRename; + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + TableNode node = dataObject as TableNode; + return node.Table.Name; + } + + public override void BuildNode (ITreeBuilder builder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + TableNode node = dataObject as TableNode; + node.RefreshEvent += (EventHandler)DispatchService.GuiDispatch (RefreshHandler); + + label = node.Table.Name; + icon = Context.GetIcon ("md-db-table"); + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + TableNode node = state as TableNode; + ITreeBuilder builder = Context.GetTreeBuilder (state); + IDbFactory fac = node.ConnectionContext.DbFactory; + + if (fac.IsCapabilitySupported ("Table", SchemaActions.Schema, TableCapabilities.Columns)) + DispatchService.GuiDispatch (delegate { + builder.AddChild (new ColumnsNode (node.ConnectionContext, node.Table)); + }); + + if (fac.IsCapabilitySupported ("Table", SchemaActions.Schema, TableCapabilities.PrimaryKeyConstraint) + || fac.IsCapabilitySupported ("Table", SchemaActions.Schema, TableCapabilities.ForeignKeyConstraint) + || fac.IsCapabilitySupported ("Table", SchemaActions.Schema, TableCapabilities.CheckConstraint) + || fac.IsCapabilitySupported ("Table", SchemaActions.Schema, TableCapabilities.UniqueConstraint) + ) + DispatchService.GuiDispatch (delegate { + builder.AddChild (new ConstraintsNode (node.ConnectionContext, node.Table)); + }); + + if (fac.IsCapabilitySupported ("Table", SchemaActions.Schema, TableCapabilities.Trigger)) + DispatchService.GuiDispatch (delegate { + builder.AddChild (new TriggersNode (node.ConnectionContext)); + }); + + //TODO: rules + + DispatchService.GuiDispatch (delegate { + builder.Expanded = true; + }); + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return true; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (sender); + builder.Update (); + } + } + + public class TableNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + public override void ActivateItem () + { + OnQueryCommand (); + } + + public override void RenameItem (string newName) + { + TableNode node = (TableNode)CurrentNode.DataItem; + if (node.Table.Name != newName) + ThreadPool.QueueUserWorkItem (new WaitCallback (RenameItemThreaded), new object[]{ node, newName }); + } + + private void RenameItemThreaded (object state) + { + object[] objs = state as object[]; + + TableNode node = objs[0] as TableNode; + string newName = objs[1] as string; + ISchemaProvider provider = node.Table.SchemaProvider; + + if (provider.IsValidName (newName)) { + provider.RenameTable (node.Table, newName); + node.Refresh (); + } else { + DispatchService.GuiDispatch (delegate () { + Services.MessageService.ShowError (String.Format ( + "Unable to rename table '{0}' to '{1}'!", + node.Table.Name, newName + )); + }); + } + node.Refresh (); + } + + [CommandHandler (ConnectionManagerCommands.Query)] + protected void OnQueryCommand () + { + TableNode node = (TableNode)CurrentNode.DataItem; + + IdentifierExpression tableId = new IdentifierExpression (node.Table.Name); + SelectStatement sel = new SelectStatement (new FromTableClause (tableId)); + + SqlQueryView view = new SqlQueryView (); + view.SelectedConnectionContext = node.ConnectionContext; + + IDbFactory fac = DbFactoryService.GetDbFactory (node.ConnectionContext.ConnectionSettings); + view.Text = fac.Dialect.GetSql (sel); + + IdeApp.Workbench.OpenDocument (view, true); + } + + [CommandHandler (ConnectionManagerCommands.SelectColumns)] + protected void OnSelectColumnsCommand () + { + ThreadPool.QueueUserWorkItem (new WaitCallback (OnSelectColumnsCommandGetColumns), CurrentNode.DataItem); + } + + private void OnSelectColumnsCommandGetColumns (object state) + { + TableNode node = (TableNode)state; + + ColumnSchemaCollection columns = node.Table.Columns; //this can invoke the schema provider, so it must be in bg thread + + DispatchService.GuiDispatch (delegate () { + SelectColumnDialog dlg = new SelectColumnDialog (true, columns); + if (dlg.Run () == (int)Gtk.ResponseType.Ok) { + IdentifierExpression tableId = new IdentifierExpression (node.Table.Name); + List<IdentifierExpression> cols = new List<IdentifierExpression> (); + foreach (ColumnSchema schema in dlg.CheckedColumns) + cols.Add (new IdentifierExpression (schema.Name)); + + SelectStatement sel = new SelectStatement (new FromTableClause (tableId), cols); + + IPooledDbConnection conn = node.ConnectionContext.ConnectionPool.Request (); + IDbCommand command = conn.CreateCommand (sel); + + conn.ExecuteTableAsync (command, new ExecuteCallback<DataTable> (OnSelectCommandThreaded), null); + } + dlg.Destroy (); + }); + } + + [CommandHandler (ConnectionManagerCommands.SelectAll)] + protected void OnSelectAllCommand () + { + TableNode node = (TableNode)CurrentNode.DataItem; + + IdentifierExpression tableId = new IdentifierExpression (node.Table.Name); + SelectStatement sel = new SelectStatement (new FromTableClause (tableId)); + + IPooledDbConnection conn = node.ConnectionContext.ConnectionPool.Request (); + IDbCommand command = conn.CreateCommand (sel); + conn.ExecuteTableAsync (command, new ExecuteCallback<DataTable> (OnSelectCommandThreaded), null); + } + + private void OnSelectCommandThreaded (IPooledDbConnection connection, DataTable table, object state) + { + connection.Release (); + + DispatchService.GuiDispatch (delegate () { + QueryResultView view = new QueryResultView (table); + IdeApp.Workbench.OpenDocument (view, true); + }); + } + + [CommandHandler (ConnectionManagerCommands.EmptyTable)] + protected void OnEmptyTable () + { + TableNode node = (TableNode)CurrentNode.DataItem; + + if (Services.MessageService.AskQuestion ( + GettextCatalog.GetString ("Are you sure you want to empty table '{0}'", node.Table.Name), + GettextCatalog.GetString ("Empty Table") + )) { + IdentifierExpression tableId = new IdentifierExpression (node.Table.Name); + DeleteStatement del = new DeleteStatement (new FromTableClause (tableId)); + + IPooledDbConnection conn = node.ConnectionContext.ConnectionPool.Request (); + IDbCommand command = conn.CreateCommand (del); + conn.ExecuteNonQueryAsync (command, new ExecuteCallback<int> (OnEmptyTableCallback), null); + } + } + + private void OnEmptyTableCallback (IPooledDbConnection connection, int result, object state) + { + connection.Release (); + + DispatchService.GuiDispatch (delegate () { + IdeApp.Workbench.StatusBar.SetMessage (GettextCatalog.GetString ("Table emptied")); + }); + } + + [CommandHandler (ConnectionManagerCommands.DropTable)] + protected void OnDropTable () + { + TableNode node = (TableNode)CurrentNode.DataItem; + if (Services.MessageService.AskQuestion ( + GettextCatalog.GetString ("Are you sure you want to drop table '{0}'", node.Table.Name), + GettextCatalog.GetString ("Drop Table") + )) { + ThreadPool.QueueUserWorkItem (new WaitCallback (OnDropTableThreaded), CurrentNode.DataItem); + } + } + + private void OnDropTableThreaded (object state) + { + TableNode node = (TableNode)state; + ISchemaProvider provider = node.ConnectionContext.SchemaProvider; + + provider.DropTable (node.Table); + OnRefreshParent (); + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + + protected void OnRefreshParent () + { + if (CurrentNode.MoveToParent ()) { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + } + + [CommandHandler (ConnectionManagerCommands.AlterTable)] + protected void OnAlterTable () + { + TableNode node = CurrentNode.DataItem as TableNode; + IDbFactory fac = node.ConnectionContext.DbFactory; + ISchemaProvider schemaProvider = node.ConnectionContext.SchemaProvider; + + if (fac.GuiProvider.ShowTableEditorDialog (schemaProvider, node.Table, false)) + ThreadPool.QueueUserWorkItem (new WaitCallback (OnAlterTableThreaded), CurrentNode.DataItem); + } + + private void OnAlterTableThreaded (object state) + { + TableNode node = (TableNode)state; + ISchemaProvider provider = node.ConnectionContext.SchemaProvider; + + provider.AlterTable (node.Table); + } + + [CommandHandler (ConnectionManagerCommands.Rename)] + protected void OnRenameTable () + { + Tree.StartLabelEdit (); + } + + [CommandUpdateHandler (ConnectionManagerCommands.DropTable)] + protected void OnUpdateDropTable (CommandInfo info) + { + BaseNode node = (BaseNode)CurrentNode.DataItem; + info.Enabled = node.ConnectionContext.DbFactory.IsActionSupported ("Table", SchemaActions.Drop); + } + + [CommandUpdateHandler (ConnectionManagerCommands.Rename)] + protected void OnUpdateRenameTable (CommandInfo info) + { + BaseNode node = (BaseNode)CurrentNode.DataItem; + info.Enabled = node.ConnectionContext.DbFactory.IsActionSupported ("Table", SchemaActions.Rename); + } + + [CommandUpdateHandler (ConnectionManagerCommands.AlterTable)] + protected void OnUpdateAlterTable (CommandInfo info) + { + BaseNode node = (BaseNode)CurrentNode.DataItem; + info.Enabled = node.ConnectionContext.DbFactory.IsActionSupported ("Table", SchemaActions.Alter); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/TablesNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/TablesNodeBuilder.cs new file mode 100644 index 0000000000..fd64ec613b --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/TablesNodeBuilder.cs @@ -0,0 +1,166 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Gtk; +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Components; +using MonoDevelop.Database.Designer; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class TablesNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public TablesNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (TablesNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/TablesNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (TablesNodeCommandHandler); } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Tables"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + label = GettextCatalog.GetString ("Tables"); + icon = Context.GetIcon ("md-db-tables"); + + BaseNode node = (BaseNode) dataObject; + node.RefreshEvent += (EventHandler)(DispatchService.GuiDispatch (RefreshHandler)); + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + BaseNode node = state as BaseNode; + ITreeBuilder builder = Context.GetTreeBuilder (state); + bool showSystemObjects = (bool)builder.Options["ShowSystemObjects"]; + TableSchemaCollection tables = node.ConnectionContext.SchemaProvider.GetTables (); + + DispatchService.GuiDispatch (delegate { + foreach (TableSchema table in tables) { + if (table.IsSystemTable && !showSystemObjects) + continue; + + builder.AddChild (new TableNode (node.ConnectionContext, table)); + } + builder.Expanded = true; + }); + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return true; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (); + + builder.UpdateChildren (); + builder.ExpandToNode (); + } + } + + public class TablesNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + + [CommandHandler (ConnectionManagerCommands.CreateTable)] + protected void OnCreateTable () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + IDbFactory fac = node.ConnectionContext.DbFactory; + ISchemaProvider schemaProvider = node.ConnectionContext.SchemaProvider; + TableSchema table = schemaProvider.GetNewTableSchema ("NewTable"); + + if (fac.GuiProvider.ShowTableEditorDialog (schemaProvider, table, true)) + ThreadPool.QueueUserWorkItem (new WaitCallback (OnCreateTableThreaded), new object[] {schemaProvider, table, node} as object); + } + + private void OnCreateTableThreaded (object state) + { + object[] objs = state as object[]; + + ISchemaProvider provider = objs[0] as ISchemaProvider; + TableSchema table = objs[1] as TableSchema; + BaseNode node = objs[2] as BaseNode; + + LoggingService.LogDebug ("ADD TABLE: {0}", table.Definition); + + IPooledDbConnection conn = provider.ConnectionPool.Request (); + conn.ExecuteNonQuery (table.Definition); + conn.Release (); + + node.Refresh (); + } + + [CommandUpdateHandler (ConnectionManagerCommands.CreateTable)] + protected void OnUpdateCreateTable (CommandInfo info) + { + BaseNode node = (BaseNode)CurrentNode.DataItem; + info.Enabled = node.ConnectionContext.DbFactory.IsActionSupported ("Table", SchemaActions.Create); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/TriggersNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/TriggersNodeBuilder.cs new file mode 100644 index 0000000000..486b02bf92 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/TriggersNodeBuilder.cs @@ -0,0 +1,123 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class TriggersNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public TriggersNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (TriggersNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/TriggersNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (TriggersNodeCommandHandler); } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Triggers"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + label = GettextCatalog.GetString ("Triggers"); + icon = Context.GetIcon ("md-db-tables"); + + BaseNode node = (BaseNode) dataObject; + node.RefreshEvent += RefreshHandler; + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + //TODO: + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return false; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (); + + if (builder != null) + builder.UpdateChildren (); + + builder.ExpandToNode (); + } + } + + public class TriggersNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + + [CommandUpdateHandler (ConnectionManagerCommands.CreateTrigger)] + protected void OnUpdateCreateTrigger (CommandInfo info) + { + BaseNode node = (BaseNode)CurrentNode.DataItem; + info.Enabled = node.ConnectionContext.DbFactory.IsActionSupported ("Trigger", SchemaActions.Create); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/TypesNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/TypesNodeBuilder.cs new file mode 100644 index 0000000000..8f20798cbc --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/TypesNodeBuilder.cs @@ -0,0 +1,116 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class TypesNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public TypesNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (TypesNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/TypesNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (TypesNodeCommandHandler); } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Types"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + label = GettextCatalog.GetString ("Types"); + icon = Context.GetIcon ("md-db-tables"); + + BaseNode node = (BaseNode) dataObject; + node.RefreshEvent += RefreshHandler; + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + //TODO: + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return false; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (); + + if (builder != null) + builder.UpdateChildren (); + + builder.ExpandToNode (); + } + } + + public class TypesNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/UserNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/UserNodeBuilder.cs new file mode 100644 index 0000000000..f20e74be08 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/UserNodeBuilder.cs @@ -0,0 +1,213 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Designer; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class UserNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public UserNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (UserNode); } + } + + public override string ContextMenuAddinPath { + get { return "/SharpDevelop/Users/ConnectionManagerPad/ContextMenu/UserNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (UserNodeCommandHandler); } + } + + public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes) + { + attributes |= NodeAttributes.AllowRename; + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + UserNode node = dataObject as UserNode; + return node.User.Name; + } + + public override void BuildNode (ITreeBuilder builder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + UserNode node = dataObject as UserNode; + node.RefreshEvent += (EventHandler)DispatchService.GuiDispatch (RefreshHandler); + + label = node.User.Name; + icon = Context.GetIcon ("md-db-user"); + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return false; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (sender); + builder.Update (); + } + } + + public class UserNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + public override void RenameItem (string newName) + { + UserNode node = (UserNode)CurrentNode.DataItem; + if (node.User.Name != newName) + ThreadPool.QueueUserWorkItem (new WaitCallback (RenameItemThreaded), new object[]{ node, newName }); + } + + private void RenameItemThreaded (object state) + { + object[] objs = state as object[]; + + UserNode node = objs[0] as UserNode; + string newName = objs[1] as string; + ISchemaProvider provider = node.User.SchemaProvider; + + if (provider.IsValidName (newName)) { + provider.RenameUser (node.User, newName); + node.Refresh (); + } else { + DispatchService.GuiDispatch (delegate () { + Services.MessageService.ShowError (String.Format ( + "Unable to rename user '{0}' to '{1}'!", + node.User.Name, newName + )); + }); + } + node.Refresh (); + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + + protected void OnRefreshParent () + { + if (CurrentNode.MoveToParent ()) { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + } + + [CommandHandler (ConnectionManagerCommands.AlterUser)] + protected void OnAlterUser () + { + UserNode node = CurrentNode.DataItem as UserNode; + IDbFactory fac = node.ConnectionContext.DbFactory; + ISchemaProvider schemaProvider = node.ConnectionContext.SchemaProvider; + + if (fac.GuiProvider.ShowUserEditorDialog (schemaProvider, node.User, false)) + ThreadPool.QueueUserWorkItem (new WaitCallback (OnAlterUserThreaded), CurrentNode.DataItem); + } + + private void OnAlterUserThreaded (object state) + { + UserNode node = (UserNode)state; + ISchemaProvider provider = node.ConnectionContext.SchemaProvider; + + provider.AlterUser (node.User); + } + + [CommandHandler (ConnectionManagerCommands.DropUser)] + protected void OnDropUser () + { + UserNode node = (UserNode)CurrentNode.DataItem; + if (Services.MessageService.AskQuestion ( + GettextCatalog.GetString ("Are you sure you want to drop user '{0}'", node.User.Name), + GettextCatalog.GetString ("Drop User") + )) { + ThreadPool.QueueUserWorkItem (new WaitCallback (OnDropUserThreaded), CurrentNode.DataItem); + } + } + + private void OnDropUserThreaded (object state) + { + UserNode node = (UserNode)state; + ISchemaProvider provider = node.ConnectionContext.SchemaProvider; + + provider.DropUser (node.User); + OnRefreshParent (); + } + + [CommandHandler (ConnectionManagerCommands.Rename)] + protected void OnRenameUser () + { + Tree.StartLabelEdit (); + } + + [CommandUpdateHandler (ConnectionManagerCommands.DropUser)] + protected void OnUpdateDropUser (CommandInfo info) + { + BaseNode node = (BaseNode)CurrentNode.DataItem; + info.Enabled = node.ConnectionContext.DbFactory.IsActionSupported ("User", SchemaActions.Drop); + } + + [CommandUpdateHandler (ConnectionManagerCommands.Rename)] + protected void OnUpdateRenameUser (CommandInfo info) + { + BaseNode node = (BaseNode)CurrentNode.DataItem; + info.Enabled = node.ConnectionContext.DbFactory.IsActionSupported ("User", SchemaActions.Rename); + } + + [CommandUpdateHandler (ConnectionManagerCommands.AlterUser)] + protected void OnUpdateAlterUser (CommandInfo info) + { + BaseNode node = (BaseNode)CurrentNode.DataItem; + info.Enabled = node.ConnectionContext.DbFactory.IsActionSupported ("User", SchemaActions.Alter); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/UsersNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/UsersNodeBuilder.cs new file mode 100644 index 0000000000..5c8c0d5280 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/UsersNodeBuilder.cs @@ -0,0 +1,155 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Gtk; +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Designer; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class UsersNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public UsersNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (UsersNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/UsersNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (UsersNodeCommandHandler); } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Users"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + label = GettextCatalog.GetString ("Users"); + icon = Context.GetIcon ("md-db-users"); + + BaseNode node = (BaseNode) dataObject; + node.RefreshEvent += (EventHandler)(DispatchService.GuiDispatch (RefreshHandler)); + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + BaseNode node = state as BaseNode; + ITreeBuilder builder = Context.GetTreeBuilder (state); + + UserSchemaCollection users = node.ConnectionContext.SchemaProvider.GetUsers (); + DispatchService.GuiDispatch (delegate { + foreach (UserSchema user in users) + builder.AddChild (new UserNode (node.ConnectionContext, user)); + builder.Expanded = true; + }); + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return true; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (sender); + + builder.UpdateChildren (); + builder.ExpandToNode (); + } + } + + public class UsersNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + + [CommandHandler (ConnectionManagerCommands.CreateUser)] + protected void OnCreateUser () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + IDbFactory fac = node.ConnectionContext.DbFactory; + ISchemaProvider schemaProvider = node.ConnectionContext.SchemaProvider; + UserSchema user = schemaProvider.GetNewUserSchema ("NewUser"); + + if (fac.GuiProvider.ShowUserEditorDialog (schemaProvider, user, true)) + ThreadPool.QueueUserWorkItem (new WaitCallback (OnCreateUserThreaded), new object[] {schemaProvider, user, node} as object); + } + + private void OnCreateUserThreaded (object state) + { + object[] objs = state as object[]; + + ISchemaProvider provider = objs[0] as ISchemaProvider; + UserSchema user = objs[1] as UserSchema; + BaseNode node = objs[2] as BaseNode; + + provider.CreateUser (user); + node.Refresh (); + } + + [CommandUpdateHandler (ConnectionManagerCommands.CreateUser)] + protected void OnUpdateCreateUser (CommandInfo info) + { + BaseNode node = (BaseNode)CurrentNode.DataItem; + info.Enabled = node.ConnectionContext.DbFactory.IsActionSupported ("User", SchemaActions.Create); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ViewNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ViewNodeBuilder.cs new file mode 100644 index 0000000000..c43ddde7e4 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ViewNodeBuilder.cs @@ -0,0 +1,234 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Designer; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class ViewNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public ViewNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (ViewNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ViewNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (ViewNodeCommandHandler); } + } + + public override void GetNodeAttributes (ITreeNavigator treeNavigator, object dataObject, ref NodeAttributes attributes) + { + attributes |= NodeAttributes.AllowRename; + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + ViewNode node = dataObject as ViewNode; + return node.View.Name; + } + + public override void BuildNode (ITreeBuilder builder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + ViewNode node = dataObject as ViewNode; + node.RefreshEvent += (EventHandler)DispatchService.GuiDispatch (RefreshHandler); + + label = node.View.Name; + icon = Context.GetIcon ("md-db-view"); + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + ViewNode node = state as ViewNode; + ITreeBuilder builder = Context.GetTreeBuilder (state); + IDbFactory fac = node.ConnectionContext.DbFactory; + + if (fac.IsActionSupported ("ViewColumn", SchemaActions.Schema)) { + DispatchService.GuiDispatch (delegate { + builder.AddChild (new ColumnsNode (node.ConnectionContext, node.View)); + builder.Expanded = true; + }); + } + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + ViewNode node = dataObject as ViewNode; + IDbFactory fac = node.ConnectionContext.DbFactory; + return fac.IsActionSupported ("ViewColumn", SchemaActions.Schema); + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (sender); + builder.Update (); + } + } + + public class ViewNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + public override void RenameItem (string newName) + { + ViewNode node = (ViewNode)CurrentNode.DataItem; + if (node.View.Name != newName) + ThreadPool.QueueUserWorkItem (new WaitCallback (RenameItemThreaded), new object[]{ node, newName }); + } + + private void RenameItemThreaded (object state) + { + object[] objs = state as object[]; + + ViewNode node = objs[0] as ViewNode; + string newName = objs[1] as string; + ISchemaProvider provider = node.View.SchemaProvider; + + if (provider.IsValidName (newName)) { + provider.RenameView (node.View, newName); + node.Refresh (); + } else { + DispatchService.GuiDispatch (delegate () { + Services.MessageService.ShowError (String.Format ( + "Unable to rename view '{0}' to '{1}'!", + node.View.Name, newName + )); + }); + } + node.Refresh (); + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + + protected void OnRefreshParent () + { + if (CurrentNode.MoveToParent ()) { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + } + + [CommandHandler (ConnectionManagerCommands.AlterView)] + protected void OnAlterView () + { + ViewNode node = CurrentNode.DataItem as ViewNode; + IDbFactory fac = node.ConnectionContext.DbFactory; + ISchemaProvider schemaProvider = node.ConnectionContext.SchemaProvider; + + if (fac.GuiProvider.ShowViewEditorDialog (schemaProvider, node.View, false)) + ThreadPool.QueueUserWorkItem (new WaitCallback (OnAlterViewThreaded), CurrentNode.DataItem); + } + + private void OnAlterViewThreaded (object state) + { + ViewNode node = (ViewNode)state; + ISchemaProvider provider = node.ConnectionContext.SchemaProvider; + + provider.AlterView (node.View); + } + + [CommandHandler (ConnectionManagerCommands.DropView)] + protected void OnDropView () + { + ViewNode node = (ViewNode)CurrentNode.DataItem; + if (Services.MessageService.AskQuestion ( + GettextCatalog.GetString ("Are you sure you want to drop view '{0}'", node.View.Name), + GettextCatalog.GetString ("Drop View") + )) { + ThreadPool.QueueUserWorkItem (new WaitCallback (OnDropViewThreaded), CurrentNode.DataItem); + } + } + + private void OnDropViewThreaded (object state) + { + ViewNode node = (ViewNode)state; + ISchemaProvider provider = node.ConnectionContext.SchemaProvider; + + provider.DropView (node.View); + OnRefreshParent (); + } + + [CommandHandler (ConnectionManagerCommands.Rename)] + protected void OnRenameView () + { + Tree.StartLabelEdit (); + } + + [CommandUpdateHandler (ConnectionManagerCommands.DropView)] + protected void OnUpdateDropView (CommandInfo info) + { + BaseNode node = (BaseNode)CurrentNode.DataItem; + info.Enabled = node.ConnectionContext.DbFactory.IsActionSupported ("View", SchemaActions.Drop); + } + + [CommandUpdateHandler (ConnectionManagerCommands.Rename)] + protected void OnUpdateRenameView (CommandInfo info) + { + BaseNode node = (BaseNode)CurrentNode.DataItem; + info.Enabled = node.ConnectionContext.DbFactory.IsActionSupported ("View", SchemaActions.Rename); + } + + [CommandUpdateHandler (ConnectionManagerCommands.AlterView)] + protected void OnUpdateAlterView (CommandInfo info) + { + BaseNode node = (BaseNode)CurrentNode.DataItem; + info.Enabled = node.ConnectionContext.DbFactory.IsActionSupported ("View", SchemaActions.Alter); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ViewsNodeBuilder.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ViewsNodeBuilder.cs new file mode 100644 index 0000000000..aa58a8fcd4 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.ConnectionManager/NodeBuilders/ViewsNodeBuilder.cs @@ -0,0 +1,160 @@ +// +// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Gtk; +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Designer; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; + +namespace MonoDevelop.Database.ConnectionManager +{ + public class ViewsNodeBuilder : TypeNodeBuilder + { + private EventHandler RefreshHandler; + + public ViewsNodeBuilder () + : base () + { + RefreshHandler = new EventHandler (OnRefreshEvent); + } + + public override Type NodeDataType { + get { return typeof (ViewsNode); } + } + + public override string ContextMenuAddinPath { + get { return "/MonoDevelop/Database/ContextMenu/ConnectionManagerPad/ViewsNode"; } + } + + public override Type CommandHandlerType { + get { return typeof (ViewsNodeCommandHandler); } + } + + public override string GetNodeName (ITreeNavigator thisNode, object dataObject) + { + return GettextCatalog.GetString ("Views"); + } + + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) + { + label = GettextCatalog.GetString ("Views"); + icon = Context.GetIcon ("md-db-views"); + + BaseNode node = (BaseNode) dataObject; + node.RefreshEvent += (EventHandler)(DispatchService.GuiDispatch (RefreshHandler)); + } + + public override void BuildChildNodes (ITreeBuilder builder, object dataObject) + { + ThreadPool.QueueUserWorkItem (new WaitCallback (BuildChildNodesThreaded), dataObject); + } + + private void BuildChildNodesThreaded (object state) + { + BaseNode node = state as BaseNode; + ITreeBuilder builder = Context.GetTreeBuilder (state); + + bool showSystemObjects = (bool)builder.Options["ShowSystemObjects"]; + ViewSchemaCollection views = node.ConnectionContext.SchemaProvider.GetViews (); + DispatchService.GuiDispatch (delegate { + foreach (ViewSchema view in views) { + if (view.IsSystemView && !showSystemObjects) + continue; + + builder.AddChild (new ViewNode (node.ConnectionContext, view)); + } + builder.Expanded = true; + }); + } + + public override bool HasChildNodes (ITreeBuilder builder, object dataObject) + { + return true; + } + + private void OnRefreshEvent (object sender, EventArgs args) + { + ITreeBuilder builder = Context.GetTreeBuilder (sender); + + builder.UpdateChildren (); + builder.ExpandToNode (); + } + } + + public class ViewsNodeCommandHandler : NodeCommandHandler + { + public override DragOperation CanDragNode () + { + return DragOperation.None; + } + + [CommandHandler (ConnectionManagerCommands.Refresh)] + protected void OnRefresh () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + node.Refresh (); + } + + [CommandHandler (ConnectionManagerCommands.CreateView)] + protected void OnCreateView () + { + BaseNode node = CurrentNode.DataItem as BaseNode; + IDbFactory fac = node.ConnectionContext.DbFactory; + ISchemaProvider schemaProvider = node.ConnectionContext.SchemaProvider; + ViewSchema view = schemaProvider.GetNewViewSchema ("NewView"); + + if (fac.GuiProvider.ShowViewEditorDialog (schemaProvider, view, true)) + ThreadPool.QueueUserWorkItem (new WaitCallback (OnCreateViewThreaded), new object[] {schemaProvider, view, node} as object); + } + + private void OnCreateViewThreaded (object state) + { + object[] objs = state as object[]; + + ISchemaProvider provider = objs[0] as ISchemaProvider; + ViewSchema view = objs[1] as ViewSchema; + BaseNode node = objs[2] as BaseNode; + + provider.CreateView (view); + node.Refresh (); + } + + [CommandUpdateHandler (ConnectionManagerCommands.CreateView)] + protected void OnUpdateCreateView (CommandInfo info) + { + BaseNode node = (BaseNode)CurrentNode.DataItem; + info.Enabled = node.ConnectionContext.DbFactory.IsActionSupported ("View", SchemaActions.Create); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/AssemblyInfo.cs.in b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/AssemblyInfo.cs.in new file mode 100644 index 0000000000..23bd6c895c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/AssemblyInfo.cs.in @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("MonoDevelop.Database.Designer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("http://www.monodevelop.com")] +[assembly: AssemblyCopyright("MIT X11 - Ben Motmans")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: AssemblyVersion("@ASSEMBLY_VERSION@")] + +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/ChangeLog b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/ChangeLog new file mode 100644 index 0000000000..b4a2a3462e --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/ChangeLog @@ -0,0 +1,144 @@ +2007-11-09 Michael Hutchinson <mhutchinson@novell.com> + + * Dialogs/TableEditorDialog.cs, Widgets/ColumnsEditorWidget.cs: Track + LoggingService API. Replace some "LogError" calls with "LogDebug" calls. + +2007-10-29 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Designer.addin.xml: Bump MD version. + +2007-10-23 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Designer.mdp: Project file names updated by change in + MD path functions. + +2007-10-16 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Designer.mdp: Fix required GTK# version. + +2007-09-26 Michael Hutchinson <mhutchinson@novell.com> + + * MonoDevelop.Database.Designer.mdp: Don't unnecessarily local-copy project + references. Don't sync EXTRA_DIST with deploy files. Add Makefile.am to + file list. + * Makefile.am: Don't deploy .addin.xml file. + +2007-09-21 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Designer.addin.xml: Bump MD version. + +2007-09-19 Ben Motmans <ben.motmans@gmail.com> + + * Dialogs/ViewEditorDialog.cs: use the correct capabilities + +2007-09-19 Ben Motmans <ben.motmans@gmail.com> + + * Commands/temp.cs, MonoDevelop.Database.Designer.mdp, Makefile.am: removed + empty file + +2007-09-16 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: link to the correct Mono.Addins dll + +2007-09-07 Ben Motmans <ben.motmans@gmail.com> + + * Dialogs/TableEditorDialog.cs, Dialogs/ProcedureEditorDialog.cs, + Dialogs/ViewEditorDialog.cs, Dialogs/UserEditorDialog.cs, + Dialogs/CreateDatabaseDialog.cs, Widgets/ColumnsEditorWidget.cs, + Widgets/PrimaryKeyConstraintEditorWidget.cs, + Widgets/CheckConstraintEditorWidget.cs, Widgets/TriggersEditorWidget.cs, + Widgets/ConstraintsEditorWidget.cs, + Widgets/ForeignKeyConstraintEditorWidget.cs, + Widgets/UniqueConstraintEditorWidget.cs, Widgets/IndicesEditorWidget.cs: + improved capabilities system + +2007-08-29 Ben Motmans <ben.motmans@gmail.com> + + * Dialogs/TableEditorDialog.cs: retrieve and store the list of database + tables for use in the constraint editor dialog + * Widgets/ConstraintsEditorWidget.cs: use the correct list of database + tables + +2007-08-29 Ben Motmans <ben.motmans@gmail.com> + + * gtk-gui/gui.stetic: changes in auto generated code + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * Widgets/ConstraintsEditorWidget.cs: use correct parameters for + ForeignKeyConstraintEditorWidget ctor + * Widgets/ForeignKeyConstraintEditorWidget.cs: fixed some copy paste errors + * gtk-gui/gui.stetic, MonoDevelop.Database.Designer.mdp, Makefile.am: use + project references instead of assembly references + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * Widgets/ForeignKeyConstraintEditorWidget.cs, + gtk-gui/MonoDevelop.Database.Designer.ForeignKeyConstraintEditorWidget.cs, + gtk-gui/gui.stetic: GUI implementation + +2007-08-03 Ben Motmans <ben.motmans@gmail.com> + + * Dialogs/TableEditorDialog.cs, Dialogs/ViewEditorDialog.cs, Dialogs/ProcedureEditorDialog.cs: + added a warning widget that can show the user whats wrong with the schema object + * Dialogs/PreviewDialog.cs: fixed the ctor + * Widgets/TriggersEditorWidget.cs, Widgets/PrimaryKeyConstraintEditorWidget.cs, + Widgets/CheckConstraintEditorWidget.cs, Widgets/UniqueConstraintEditorWidget.cs, + Widgets/ForeignKeyConstraintEditorWidget.cs, Widgets/IndicesEditorWidget.cs, + Widgets/ColumnsEditorWidget.cs: Added support for a error message while validating the control + +2007-08-02 Ben Motmans <ben.motmans@gmail.com> + + * Widgets/UniqueConstraintEditorWidget.cs: removed the "Columns" column from the listview, + Validate and FillSchemaObjects implementation + * Widgets/TriggersEditorWidget.cs, Widgets/PrimaryKeyConstraintEditorWidget.cs, + Widgets/CheckConstraintEditorWidget.cs: Validate and FillSchemaObjects implementation + * Widgets/ForeignKeyConstraintEditorWidget.cs, Widgets/IndicesEditorWidget.cs: FillSchemaObjects stub + * Widgets/ConstraintsEditorWidget.cs: ValidateSchemaObjects implementation + * Widgets/ColumnsEditorWidget.cs: FillSchemaObjects implementation, show the default length + if the datatype is changed + * Dialogs/TableEditorDialog.cs: Fill objects when Ok is clicked + + * Widgets/UniqueConstraintEditorWidget.cs: implementation of the treeview with handlers + * Widgets/TriggersEditorWidget.cs: added a column for the TriggerFireType + +2007-08-01 Ben Motmans <ben.motmans@gmail.com> + + * Widgets/UniqueConstraintEditorWidget.cs: implemented Add and Remove button clicks + * Widgets/TriggersEditorWidget.cs: Add and initialize implementation + * Widgets/ColumnsEditorWidget.cs: better visualisation of database capabilities + * Widgets/CheckConstraintEditorWidget.cs: implemented Add and Remove button clicks + * Dialogs/TableEditorDialog.cs: create a clone when altering the table and various + small bugfixes + * Dialogs/ProcedureEditorDialog.cs, Dialogs/ViewEditorDialog.cs: show the alter + statement instead of the create statement when the dialog is in alter mode + * Dialogs/PreviewDialog.cs: Added a SqlEditor widget + +2007-07-31 Ben Motmans <ben.motmans@gmail.com> + + * Dialogs/TableEditorDialog.cs: various improvements + * Dialogs/ViewEditorDialog.cs: dialog implementation + * Dialogs/ProcedureEditorDialog.cs: dialog implementation + * Widgets/ColumnsEditorWidget.cs: various bugfixes + * Widgets/ForeignKeyConstraintEditorWidget.cs, Widgets/UniqueConstraintEditorWidget.cs, + Widgets/PrimaryKeyConstraintEditorWidget.cs, Widgets/ConstraintsEditorWidget.cs, + Widgets/CheckConstraintEditorWidget.cs: Added separate widgets to edit each type of constraint + +2007-07-25 Ben Motmans <ben.motmans@gmail.com> + + * Dialogs/TableEditorDialog.cs: small bugfixes + * Dialogs/CreateDatabaseDialog.cs: dialog to create a new database + * Dialogs/ViewEditorDialog.cs, Dialogs/UserEditorDialog.cs, + Dialogs/ProcedureEditorDialog.cs, Dialogs/PreviewDialog.cs: + Stubs for the dialogs + * MonoDevelop.Database.Designer.addin.xml: addin definitions + * Widgets/TriggersEditorWidget.cs, Widgets/IndicesEditorWidget.cs, + Widgets/ConstraintsEditorWidget.cs: stubs with ctor + * Widgets/ColumnsEditorWidget.cs: Various improvements and bugfixes + * Widgets/CommentEditorWidget.cs: Widget to edit comment + +2007-07-18 Ben Motmans <ben.motmans@gmail.com> + + * Dialogs/TableEditorDialog.cs, Widgets/TriggersEditorWidget.cs, + Widgets/IndicesEditorWidget.cs, Widgets/ConstraintsEditorWidget.cs, + Widgets/ColumnsEditorWidget.cs: Widgets and dialogs used by the Table Editor (unfinished) diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/CreateDatabaseDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/CreateDatabaseDialog.cs new file mode 100644 index 0000000000..245d3041a3 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/CreateDatabaseDialog.cs @@ -0,0 +1,130 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.Designer +{ + public partial class CreateDatabaseDialog : Gtk.Dialog + { + private DatabaseConnectionContext context; + + //TODO: validate db name + check for duplicates + public CreateDatabaseDialog() + { + this.Build(); + } + + public DatabaseConnectionContext DatabaseConnection { + get { return context; } + } + + protected virtual void OkClicked (object sender, System.EventArgs e) + { + context = comboConnections.DatabaseConnection; + if (context.IsTemporary) { + //make it a real connection context and fill in the database + context.ConnectionSettings.Database = entryDatabase.Text; + context.ConnectionSettings.Name = entryName.Text; + context.IsTemporary = false; + } else { + //create a copy of the settings and create a new context + DatabaseConnectionSettings settings = new DatabaseConnectionSettings (context.ConnectionSettings); + settings.Database = entryDatabase.Text; + settings.Name = entryName.Text; + context = new DatabaseConnectionContext (settings); + } + + Respond (ResponseType.Ok); + Destroy (); + } + + protected virtual void CancelClicked (object sender, System.EventArgs e) + { + Respond (ResponseType.Cancel); + Destroy (); + } + + protected virtual void SaveAsClicked (object sender, System.EventArgs e) + { + DatabaseConnectionContext context = comboConnections.DatabaseConnection; + if (context == null) + return; + + IDbFactory fac = context.DbFactory; + + string database = null; + if (fac.GuiProvider.ShowSelectDatabaseDialog (true, out database)) + entryDatabase.Text = database; + } + + protected virtual void NewClicked (object sender, System.EventArgs e) + { + DatabaseConnectionSettingsDialog dlg = new DatabaseConnectionSettingsDialog (true); + if (dlg.Run () == (int)ResponseType.Ok) { + DatabaseConnectionContext context = new DatabaseConnectionContext (dlg.ConnectionSettings, true); + context.IsTemporary = true; + comboConnections.AddDatabaseConnectionContext (context); + comboConnections.DatabaseConnection = context; + } + } + + protected virtual void DatabaseNameChanged (object sender, EventArgs e) + { + CheckOkState (); + } + + protected virtual void ConnectionChanged (object sender, EventArgs e) + { + CheckOkState (); + + if (entryName.Text.Length == 0) { + DatabaseConnectionContext context = comboConnections.DatabaseConnection; + entryName.Text = context.ConnectionSettings.Name; + } + } + + private void CheckOkState () + { + DatabaseConnectionContext context = comboConnections.DatabaseConnection; + if (context != null) + buttonSelect.Sensitive = context.DbFactory.IsCapabilitySupported ("ConnectionSettings", SchemaActions.Schema, ConnectionSettingsCapabilities.SelectDatabase); + buttonOk.Sensitive = context != null && + entryDatabase.Text.Length > 0 && entryName.Text.Length > 0; + } + + protected virtual void NameChanged (object sender, System.EventArgs e) + { + CheckOkState (); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/PreviewDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/PreviewDialog.cs new file mode 100644 index 0000000000..b8a98ae685 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/PreviewDialog.cs @@ -0,0 +1,70 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+ +using Gtk;
+using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Components; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.Designer +{ + public partial class PreviewDialog : Gtk.Dialog + { + public PreviewDialog (string sql) + { + this.Build(); + + sqlEditor.TextChanged += new EventHandler (SqlChanged); + sqlEditor.Text = sql; + } + + public string Text { + get { return sqlEditor.Text; } + set { sqlEditor.Text = value; } + } + + protected virtual void CancelClicked (object sender, EventArgs e) + { + Respond (ResponseType.Cancel); + Hide (); + } + + protected virtual void OkClicked (object sender, EventArgs e) + { + Respond (ResponseType.Ok); + Hide (); + } + + protected virtual void SqlChanged (object sender, EventArgs e) + { + buttonOk.Sensitive = sqlEditor.Text.Length > 0; + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/ProcedureEditorDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/ProcedureEditorDialog.cs new file mode 100644 index 0000000000..90b39e4edb --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/ProcedureEditorDialog.cs @@ -0,0 +1,135 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+ +using Gtk; +using GtkSourceView;
+using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Components; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.Designer +{ + public partial class ProcedureEditorDialog : Gtk.Dialog + { + private SchemaActions action; + + private Notebook notebook; + + private ISchemaProvider schemaProvider; + private ProcedureSchema procedure; + + private CommentEditorWidget commentEditor; + private SqlEditorWidget sqlEditor; + + public ProcedureEditorDialog (ISchemaProvider schemaProvider, ProcedureSchema procedure, bool create) + { + if (schemaProvider == null) + throw new ArgumentNullException ("schemaProvider"); + if (procedure == null) + throw new ArgumentNullException ("procedure"); + + this.schemaProvider = schemaProvider; + this.procedure = procedure; + this.action = create ? SchemaActions.Create : SchemaActions.Alter; + + this.Build(); + + if (create) + Title = GettextCatalog.GetString ("Create Procedure"); + else + Title = GettextCatalog.GetString ("Alter Procedure"); + + notebook = new Notebook (); + + sqlEditor = new SqlEditorWidget (); + sqlEditor.TextChanged += new EventHandler (SqlChanged); + notebook.AppendPage (sqlEditor, new Label (GettextCatalog.GetString ("Definition"))); + + IDbFactory fac = schemaProvider.ConnectionPool.DbFactory; + if (fac.IsCapabilitySupported ("Procedure", action, ProcedureCapabilities.Comment)) { + commentEditor = new CommentEditorWidget (); + notebook.AppendPage (commentEditor, new Label (GettextCatalog.GetString ("Comment"))); + } + + entryName.Text = procedure.Name; + if (!create) { + sqlEditor.Text = schemaProvider.GetProcedureAlterStatement (procedure); + commentEditor.Comment = procedure.Comment; + } + + vboxContent.PackStart (notebook, true, true, 0); + vboxContent.ShowAll (); + SetWarning (null); + } + + protected virtual void OkClicked (object sender, EventArgs e) + { + procedure.Name = entryName.Text; + procedure.Definition = sqlEditor.Text; + procedure.Comment = commentEditor.Comment; + + Respond (ResponseType.Ok); + Hide (); + } + + protected virtual void CancelClicked (object sender, EventArgs e) + { + Respond (ResponseType.Cancel); + Hide (); + } + + protected virtual void NameChanged (object sender, EventArgs e) + { + CheckState (); + } + + protected virtual void SqlChanged (object sender, EventArgs e) + { + CheckState (); + } + + private void CheckState () + { + buttonOk.Sensitive = entryName.Text.Length > 0 && sqlEditor.Text.Length > 0; + //TODO: check for duplicate name + } + + protected virtual void SetWarning (string msg) + { + if (msg == null) { + hboxWarning.Hide (); + labelWarning.Text = ""; + } else { + hboxWarning.ShowAll (); + labelWarning.Text = msg; + } + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/TableEditorDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/TableEditorDialog.cs new file mode 100644 index 0000000000..c8f3657d45 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/TableEditorDialog.cs @@ -0,0 +1,262 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+ +using Gtk;
+using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Components; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.Designer +{ + public partial class TableEditorDialog : Gtk.Dialog + { + private SchemaActions action; + + private ISchemaProvider schemaProvider; + private TableSchemaCollection tables; + private TableSchema table; + private TableSchema originalTable; + private ColumnSchemaCollection columns; + private ConstraintSchemaCollection constraints; + private IndexSchemaCollection indexes; + private TriggerSchemaCollection triggers; + private DataTypeSchemaCollection dataTypes; + + private Notebook notebook; + + private ColumnsEditorWidget columnEditor; + private ConstraintsEditorWidget constraintEditor; + private IndicesEditorWidget indexEditor; + private TriggersEditorWidget triggerEditor; + private CommentEditorWidget commentEditor; + + public TableEditorDialog (ISchemaProvider schemaProvider, TableSchema table, bool create) + { + if (schemaProvider == null) + throw new ArgumentNullException ("schemaProvider"); + if (table == null) + throw new ArgumentNullException ("table"); + + this.schemaProvider = schemaProvider; + this.originalTable = table; + this.table = table; + this.action = create ? SchemaActions.Create : SchemaActions.Alter; + + this.Build(); + + if (create) + Title = GettextCatalog.GetString ("Create Table"); + else + Title = GettextCatalog.GetString ("Alter Table"); + + notebook = new Notebook (); + vboxContent.PackStart (notebook, true, true, 0); + + columnEditor = new ColumnsEditorWidget (schemaProvider, action); + columnEditor.ContentChanged += new EventHandler (OnContentChanged); + notebook.AppendPage (columnEditor, new Label (GettextCatalog.GetString ("Columns"))); + + //TODO: there is a diff between col and table constraints + IDbFactory fac = schemaProvider.ConnectionPool.DbFactory; + if (fac.IsCapabilitySupported ("Table", action, TableCapabilities.Constraints)) { + constraintEditor = new ConstraintsEditorWidget (schemaProvider, action); + constraintEditor.ContentChanged += new EventHandler (OnContentChanged); + notebook.AppendPage (constraintEditor, new Label (GettextCatalog.GetString ("Constraints"))); + } + + //TODO: + //indexEditor = new IndicesEditorWidget (schemaProvider); + //notebook.AppendPage (indexEditor, new Label (GettextCatalog.GetString ("Indexes"))); + + if (fac.IsCapabilitySupported ("Table", action, TableCapabilities.Trigger)) { + triggerEditor = new TriggersEditorWidget (schemaProvider, action); + triggerEditor.ContentChanged += new EventHandler (OnContentChanged); + notebook.AppendPage (triggerEditor, new Label (GettextCatalog.GetString ("Triggers"))); + } + + if (fac.IsCapabilitySupported ("Table", action, TableCapabilities.Comment)) { + commentEditor = new CommentEditorWidget (); + notebook.AppendPage (commentEditor, new Label (GettextCatalog.GetString ("Comment"))); + } + + notebook.Page = 0; + + entryName.Text = originalTable.Name; + + WaitDialog.ShowDialog ("Loading table data ..."); + + notebook.Sensitive = false; + ThreadPool.QueueUserWorkItem (new WaitCallback (InitializeThreaded)); + + vboxContent.ShowAll (); + SetWarning (null); + } + + private void InitializeThreaded (object state) + { + tables = schemaProvider.GetTables (); + dataTypes = schemaProvider.GetDataTypes (); + columns = originalTable.Columns; + constraints = originalTable.Constraints; + triggers = originalTable.Triggers; + //TODO: indices + indexes = new IndexSchemaCollection (); + + System.Text.StringBuilder builder = new System.Text.StringBuilder (); + builder.Append ("Loading editor for TABLE "); + builder.Append (originalTable.Name); + builder.AppendLine (); + builder.Append (" columns = "); + builder.Append (columns.Count); + builder.AppendLine (); + builder.Append ("constraints = "); + builder.Append (constraints.Count); + builder.AppendLine (); + + try { + foreach (ColumnSchema col in columns) { + int dummy = col.Constraints.Count; //get column constraints + builder.Append ("CONSTRAINTS "); + builder.Append (col.Name); + builder.Append (" "); + builder.Append (dummy); + builder.AppendLine (); + } + LoggingService.LogDebug (builder.ToString ()); + } catch (Exception ee) { + LoggingService.LogDebug (builder.ToString ()); + LoggingService.LogError (ee.ToString ()); + } + + if (action == SchemaActions.Alter) //make a duplicate if we are going to alter the table + this.table = originalTable.Clone () as TableSchema; + + DispatchService.GuiDispatch (delegate () { + InitializeGui (); + }); + } + + private void InitializeGui () + { + notebook.Sensitive = true; + WaitDialog.HideDialog (); + + LoggingService.LogDebug ("TableEditorDialog: entering InitializeGui"); + + columnEditor.Initialize (table, columns, constraints, dataTypes); + if (constraintEditor != null) + constraintEditor.Initialize (tables, table, columns, constraints, dataTypes); + if (triggerEditor != null) + triggerEditor.Initialize (table, triggers); + LoggingService.LogDebug ("TableEditorDialog: leaving InitializeGui"); + } + + protected virtual void CancelClicked (object sender, System.EventArgs e) + { + Respond (ResponseType.Cancel); + Hide (); + } + + protected virtual void OkClicked (object sender, System.EventArgs e) + { + columnEditor.FillSchemaObjects (); + if (constraintEditor != null) + constraintEditor.FillSchemaObjects (); + if (triggerEditor != null) + triggerEditor.FillSchemaObjects (); + if (commentEditor != null) + table.Comment = commentEditor.Comment; + + if (action == SchemaActions.Create) + table.Definition = schemaProvider.GetTableCreateStatement (table); + else + table.Definition = schemaProvider.GetTableAlterStatement (table); + + if (checkPreview.Active) { + PreviewDialog dlg = new PreviewDialog (table.Definition); + if (dlg.Run () == (int)ResponseType.Ok) { + table.Definition = dlg.Text; + + Respond (ResponseType.Ok); + Hide (); + } + dlg.Destroy (); + } else { + Respond (ResponseType.Ok); + Hide (); + } + } + + protected virtual void NameChanged (object sender, System.EventArgs e) + { + table.Name = entryName.Text; + } + + protected virtual void OnContentChanged (object sender, EventArgs args) + { + string msg; + + bool val = entryName.Text.Length > 0; + if (!val) { + msg = GettextCatalog.GetString ("No name specified."); + goto sens; + } + + val &= columnEditor.ValidateSchemaObjects (out msg); + if (!val) goto sens; + + if (constraintEditor != null) { + val &= constraintEditor.ValidateSchemaObjects (out msg); + if (!val) goto sens; + } + + if (triggerEditor != null) { + val &= triggerEditor.ValidateSchemaObjects (out msg); + if (!val) goto sens; + } + + //TODO: validate indexEditor + sens: + SetWarning (msg); + buttonOk.Sensitive = val; + } + + protected virtual void SetWarning (string msg) + { + if (msg == null) { + hboxWarning.Hide (); + labelWarning.Text = ""; + } else { + hboxWarning.ShowAll (); + labelWarning.Text = msg; + } + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/UserEditorDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/UserEditorDialog.cs new file mode 100644 index 0000000000..54edb35227 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/UserEditorDialog.cs @@ -0,0 +1,84 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+ +using Gtk;
+using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Components; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.Designer +{ + public partial class UserEditorDialog : Gtk.Dialog + { + private SchemaActions action; + + private Notebook notebook; + + private ISchemaProvider schemaProvider; + private UserSchema user; + + public UserEditorDialog (ISchemaProvider schemaProvider, UserSchema user, bool create) + { + this.Build(); + + if (schemaProvider == null) + throw new ArgumentNullException ("schemaProvider"); + if (user == null) + throw new ArgumentNullException ("user"); + + this.schemaProvider = schemaProvider; + this.user = user; + this.action = create ? SchemaActions.Create : SchemaActions.Alter; + + this.Build(); + + if (create) + Title = GettextCatalog.GetString ("Create User"); + else + Title = GettextCatalog.GetString ("Alter User"); + + notebook = new Notebook (); + vboxContent.PackStart (notebook, true, true, 0); + vboxContent.ShowAll (); + } + + protected virtual void OkClicked (object sender, System.EventArgs e) + { + } + + protected virtual void CancelClicked (object sender, System.EventArgs e) + { + } + + protected virtual void NameChanged (object sender, System.EventArgs e) + { + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/ViewEditorDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/ViewEditorDialog.cs new file mode 100644 index 0000000000..39539ad442 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Dialogs/ViewEditorDialog.cs @@ -0,0 +1,137 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+ +using Gtk; +using GtkSourceView;
+using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Components; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.Designer +{ + public partial class ViewEditorDialog : Gtk.Dialog + { + private SchemaActions action; + + private Notebook notebook; + + private ISchemaProvider schemaProvider; + private ViewSchema view; + + private CommentEditorWidget commentEditor; + private SqlEditorWidget sqlEditor; + + public ViewEditorDialog (ISchemaProvider schemaProvider, ViewSchema view, bool create) + { + if (schemaProvider == null) + throw new ArgumentNullException ("schemaProvider"); + if (view == null) + throw new ArgumentNullException ("view"); + + this.schemaProvider = schemaProvider; + this.view = view; + this.action = create ? SchemaActions.Create : SchemaActions.Alter; + + this.Build(); + + if (create) + Title = GettextCatalog.GetString ("Create View"); + else + Title = GettextCatalog.GetString ("Alter View"); + + notebook = new Notebook (); + + sqlEditor = new SqlEditorWidget (); + sqlEditor.TextChanged += new EventHandler (SqlChanged); + notebook.AppendPage (sqlEditor, new Label (GettextCatalog.GetString ("Definition"))); + + IDbFactory fac = schemaProvider.ConnectionPool.DbFactory; + if (fac.IsCapabilitySupported ("View", action, ViewCapabilities.Comment)) { + commentEditor = new CommentEditorWidget (); + notebook.AppendPage (commentEditor, new Label (GettextCatalog.GetString ("Comment"))); + } + + notebook.Page = 0; + + entryName.Text = view.Name; + if (!create) { + sqlEditor.Text = schemaProvider.GetViewAlterStatement (view); + commentEditor.Comment = view.Comment; + } + + vboxContent.PackStart (notebook, true, true, 0); + vboxContent.ShowAll (); + SetWarning (null); + } + + protected virtual void CancelClicked (object sender, System.EventArgs e) + { + Respond (ResponseType.Cancel); + Hide (); + } + + protected virtual void OkClicked (object sender, System.EventArgs e) + { + view.Name = entryName.Text; + view.Definition = sqlEditor.Text; + view.Comment = commentEditor.Comment; + + Respond (ResponseType.Ok); + Hide (); + } + + protected virtual void NameChanged (object sender, System.EventArgs e) + { + CheckState (); + } + + protected virtual void SqlChanged (object sender, EventArgs e) + { + CheckState (); + } + + private void CheckState () + { + buttonOk.Sensitive = entryName.Text.Length > 0 && sqlEditor.Text.Length > 0; + //TODO: check for duplicate name + } + + protected virtual void SetWarning (string msg) + { + if (msg == null) { + hboxWarning.Hide (); + labelWarning.Text = ""; + } else { + hboxWarning.ShowAll (); + labelWarning.Text = msg; + } + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Makefile.am b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Makefile.am new file mode 100644 index 0000000000..dca1ae04dc --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Makefile.am @@ -0,0 +1,74 @@ +ADDIN_BUILD = $(top_builddir)/build/AddIns/MonoDevelop.Database +ASSEMBLY = $(ADDIN_BUILD)/MonoDevelop.Database.Designer.dll +REFS = \ + $(GTK_SHARP_LIBS) \ + $(GTKSOURCEVIEW_SHARP_LIBS) \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Components.dll \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Sql.dll \ + -r:$(top_builddir)/build/bin/Mono.Addins.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Components.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.Gui.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Ide.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Projects.dll \ + -r:Mono.Posix \ + -r:System + +FILES = \ + Dialogs/CreateDatabaseDialog.cs \ + Dialogs/PreviewDialog.cs \ + Dialogs/ProcedureEditorDialog.cs \ + Dialogs/TableEditorDialog.cs \ + Dialogs/UserEditorDialog.cs \ + Dialogs/ViewEditorDialog.cs \ + gtk-gui/generated.cs \ + gtk-gui/MonoDevelop.Database.Designer.CheckConstraintEditorWidget.cs \ + gtk-gui/MonoDevelop.Database.Designer.ColumnsEditorWidget.cs \ + gtk-gui/MonoDevelop.Database.Designer.CommentEditorWidget.cs \ + gtk-gui/MonoDevelop.Database.Designer.ConstraintsEditorWidget.cs \ + gtk-gui/MonoDevelop.Database.Designer.CreateDatabaseDialog.cs \ + gtk-gui/MonoDevelop.Database.Designer.ForeignKeyConstraintEditorWidget.cs \ + gtk-gui/MonoDevelop.Database.Designer.IndicesEditorWidget.cs \ + gtk-gui/MonoDevelop.Database.Designer.PreviewDialog.cs \ + gtk-gui/MonoDevelop.Database.Designer.PrimaryKeyConstraintEditorWidget.cs \ + gtk-gui/MonoDevelop.Database.Designer.ProcedureEditorDialog.cs \ + gtk-gui/MonoDevelop.Database.Designer.TableEditorDialog.cs \ + gtk-gui/MonoDevelop.Database.Designer.TriggersEditorWidget.cs \ + gtk-gui/MonoDevelop.Database.Designer.UniqueConstraintEditorWidget.cs \ + gtk-gui/MonoDevelop.Database.Designer.UserEditorDialog.cs \ + gtk-gui/MonoDevelop.Database.Designer.ViewEditorDialog.cs \ + Widgets/CheckConstraintEditorWidget.cs \ + Widgets/ColumnsEditorWidget.cs \ + Widgets/CommentEditorWidget.cs \ + Widgets/ConstraintsEditorWidget.cs \ + Widgets/ForeignKeyConstraintEditorWidget.cs \ + Widgets/IndicesEditorWidget.cs \ + Widgets/PrimaryKeyConstraintEditorWidget.cs \ + Widgets/TriggersEditorWidget.cs \ + Widgets/UniqueConstraintEditorWidget.cs + +RES = \ + gtk-gui/gui.stetic \ + gtk-gui/objects.xml \ + MonoDevelop.Database.Designer.addin.xml + +if ENABLE_DATABASE +all: $(ASSEMBLY) $(ADDIN_BUILD) +else
+all:
+endif + +$(ASSEMBLY): $(FILES) $(build_resources) + mkdir -p $(ADDIN_BUILD) + $(CSC) $(CSC_FLAGS) $(REFS) $(build_resources:%=/resource:%) $(build_sources) -out:$@ -target:library + + +if ENABLE_DATABASE +assemblydir = $(MD_ADDIN_DIR)/MonoDevelop.Database +assembly_DATA = $(ASSEMBLY) +endif + +CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb +EXTRA_DIST = $(FILES) $(RES) + +include $(top_srcdir)/Makefile.include diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/MonoDevelop.Database.Designer.addin.xml b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/MonoDevelop.Database.Designer.addin.xml new file mode 100644 index 0000000000..7ab4fbf468 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/MonoDevelop.Database.Designer.addin.xml @@ -0,0 +1,21 @@ +<Addin id = "Database.Designer" + namespace = "MonoDevelop" + name = "MonoDevelop Database Designer" + author = "Ben Motmans" + copyright = "MIT X11" + url = "http://www.monodevelop.com" + description = "Database Designer Module" + version = "0.17.0"> + + <Runtime> + <Import assembly="MonoDevelop.Database.Designer.dll"/> + </Runtime> + + <Dependencies> + <Addin id="Core" version="0.17.0"/> + <Addin id="Core.Gui" version="0.17.0"/> + <Addin id="Ide" version="0.17.0"/> + <Addin id="Database.Sql" version="0.17.0"/> + </Dependencies> + +</Addin>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/MonoDevelop.Database.Designer.mdp b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/MonoDevelop.Database.Designer.mdp new file mode 100644 index 0000000000..da64cd7f5d --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/MonoDevelop.Database.Designer.mdp @@ -0,0 +1,94 @@ +<Project name="MonoDevelop.Database.Designer" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assemblyKeyFile="." assembly="MonoDevelop.Database.Designer" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Designer" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="gtk-gui/gui.stetic" subtype="Code" buildaction="EmbedAsResource" /> + <File name="gtk-gui/generated.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/TriggersEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Designer.TriggersEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/ColumnsEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Designer.ColumnsEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/ConstraintsEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Designer.ConstraintsEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/IndicesEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Designer.IndicesEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialogs/TableEditorDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Designer.TableEditorDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialogs/CreateDatabaseDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Designer.CreateDatabaseDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialogs/ViewEditorDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Designer.ViewEditorDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialogs/ProcedureEditorDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Designer.ProcedureEditorDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/CommentEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Designer.CommentEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialogs/PreviewDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Designer.PreviewDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialogs/UserEditorDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Designer.UserEditorDialog.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/ForeignKeyConstraintEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Designer.ForeignKeyConstraintEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/CheckConstraintEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Designer.CheckConstraintEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/PrimaryKeyConstraintEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Designer.PrimaryKeyConstraintEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="Widgets/UniqueConstraintEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="gtk-gui/MonoDevelop.Database.Designer.UniqueConstraintEditorWidget.cs" subtype="Code" buildaction="Compile" /> + <File name="MonoDevelop.Database.Designer.addin.xml" subtype="Code" buildaction="EmbedAsResource" /> + <File name="gtk-gui/objects.xml" subtype="Code" buildaction="EmbedAsResource" /> + <File name="Makefile.am" subtype="Code" buildaction="Nothing" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" /> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="gtksourceview-sharp, Version=1.0.0.2, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Components" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Sql" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core.Gui" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Components" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Ide" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Projects" /> + <ProjectReference type="Project" localcopy="False" refto="Mono.Addins" /> + <ProjectReference type="Gac" localcopy="True" refto="pango-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="atk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + </References> + <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am" BuildTargetName="" CleanTargetName="" SyncReferences="True" IsAutotoolsProject="True" RelativeConfigureInPath="../../../"> + <BuildFilesVar Sync="True" Name="FILES" /> + <DeployFilesVar /> + <ResourcesVar Sync="True" Name="RES" /> + <OthersVar /> + <GacRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <AsmRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <ProjectRefVar Sync="True" Name="REFS" Prefix="-r:" /> + </MonoDevelop.Autotools.MakefileInfo> + <GtkDesignInfo isWidgetLibrary="True"> + <ExportedWidgets> + <Widget>MonoDevelop.Database.Designer.ColumnEditorWidget</Widget> + <Widget>MonoDevelop.Database.Designer.TriggersEditorWidget</Widget> + <Widget>MonoDevelop.Database.Designer.ColumnsEditorWidget</Widget> + <Widget>MonoDevelop.Database.Designer.ConstraintsEditorWidget</Widget> + <Widget>MonoDevelop.Database.Designer.IndicesEditorWidget</Widget> + <Widget>MonoDevelop.Database.Designer.CommentEditorWidget</Widget> + <Widget>MonoDevelop.Database.Designer.SelectColumnConstraintWidget</Widget> + <Widget>MonoDevelop.Database.Designer.ForeignKeyConstraintEditorWidget</Widget> + <Widget>MonoDevelop.Database.Designer.CheckConstraintEditorWidget</Widget> + <Widget>MonoDevelop.Database.Designer.PrimaryKeyConstraintEditorWidget</Widget> + <Widget>MonoDevelop.Database.Designer.UniqueConstraintEditorWidget</Widget> + </ExportedWidgets> + </GtkDesignInfo> +</Project>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/CheckConstraintEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/CheckConstraintEditorWidget.cs new file mode 100644 index 0000000000..59a1e8a9d2 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/CheckConstraintEditorWidget.cs @@ -0,0 +1,286 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using Gtk; +using System; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Components; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.Designer +{ + public partial class CheckConstraintEditorWidget : Gtk.Bin + { + public event EventHandler ContentChanged; + + private ISchemaProvider schemaProvider; + private TableSchema table; + private ColumnSchemaCollection columns; + private ConstraintSchemaCollection constraints; + + private ListStore store; + private SortedColumnListStore storeColumns; + + private const int colNameIndex = 0; + private const int colColumnNameIndex = 1; + private const int colIsColumnConstraintIndex = 2; + private const int colSourceIndex = 3; + private const int colObjIndex = 4; + + private bool columnConstraintsSupported; + private bool tableConstraintsSupported; + + private SchemaActions action; + + public CheckConstraintEditorWidget (ISchemaProvider schemaProvider, SchemaActions action, TableSchema table, ColumnSchemaCollection columns, ConstraintSchemaCollection constraints) + { + if (columns == null) + throw new ArgumentNullException ("columns"); + if (table == null) + throw new ArgumentNullException ("table"); + if (constraints == null) + throw new ArgumentNullException ("constraints"); + if (schemaProvider == null) + throw new ArgumentNullException ("schemaProvider"); + + this.schemaProvider = schemaProvider; + this.table = table; + this.columns = columns; + this.constraints = constraints; + this.action = action; + + this.Build(); + + store = new ListStore (typeof (string), typeof (string), typeof (bool), typeof (string), typeof (object)); + storeColumns = new SortedColumnListStore (columns); + + listCheck.Model = store; + + TreeViewColumn colName = new TreeViewColumn (); + TreeViewColumn colColumn = new TreeViewColumn (); + TreeViewColumn colIsColumnConstraint = new TreeViewColumn (); + + colName.Title = GettextCatalog.GetString ("Name"); + colColumn.Title = GettextCatalog.GetString ("Column"); + colIsColumnConstraint.Title = GettextCatalog.GetString ("Column Constraint"); + + colColumn.MinWidth = 120; //request a bigger width + + CellRendererText nameRenderer = new CellRendererText (); + CellRendererCombo columnRenderer = new CellRendererCombo (); + CellRendererToggle isColumnConstraintRenderer = new CellRendererToggle (); + + nameRenderer.Editable = true; + nameRenderer.Edited += new EditedHandler (NameEdited); + + columnRenderer.Model = storeColumns.Store; + columnRenderer.TextColumn = SortedColumnListStore.ColNameIndex; + columnRenderer.Editable = true; + columnRenderer.Edited += new EditedHandler (ColumnEdited); + + isColumnConstraintRenderer.Activatable = true; + isColumnConstraintRenderer.Toggled += new ToggledHandler (IsColumnConstraintToggled); + + colName.PackStart (nameRenderer, true); + colColumn.PackStart (columnRenderer, true); + colIsColumnConstraint.PackStart (isColumnConstraintRenderer, true); + + colName.AddAttribute (nameRenderer, "text", colNameIndex); + colColumn.AddAttribute (columnRenderer, "text", colColumnNameIndex); + colIsColumnConstraint.AddAttribute (isColumnConstraintRenderer, "active", colIsColumnConstraintIndex); + + IDbFactory fac = schemaProvider.ConnectionPool.DbFactory; + columnConstraintsSupported = fac.IsCapabilitySupported ("TableColumn", action, TableCapabilities.CheckConstraint); + tableConstraintsSupported = fac.IsCapabilitySupported ("Table", action, TableCapabilities.CheckConstraint); + + listCheck.AppendColumn (colName); + if (columnConstraintsSupported) + listCheck.AppendColumn (colColumn); + if (columnConstraintsSupported && tableConstraintsSupported) + listCheck.AppendColumn (colIsColumnConstraint); + + listCheck.Selection.Changed += new EventHandler (OnSelectionChanged); + sqlEditor.TextChanged += new EventHandler (SourceChanged); + + foreach (CheckConstraintSchema check in constraints.GetConstraints (ConstraintType.Check)) + AddConstraint (check); + //TODO: also col constraints + + ShowAll (); + } + + protected virtual void AddClicked (object sender, EventArgs e) + { + CheckConstraintSchema check = schemaProvider.GetNewCheckConstraintSchema ("check_new"); + int index = 1; + while (constraints.Contains (check.Name)) + check.Name = "check_new" + (index++); + constraints.Add (check); + AddConstraint (check); + EmitContentChanged (); + } + + protected virtual void RemoveClicked (object sender, EventArgs e) + { + TreeIter iter; + if (listCheck.Selection.GetSelected (out iter)) { + CheckConstraintSchema check = store.GetValue (iter, colObjIndex) as CheckConstraintSchema; + + if (Services.MessageService.AskQuestion ( + GettextCatalog.GetString ("Are you sure you want to remove constraint '{0}'?", check.Name), + GettextCatalog.GetString ("Remove Constraint") + )) { + store.Remove (ref iter); + constraints.Remove (check); + EmitContentChanged (); + } + } + } + + protected virtual void OnSelectionChanged (object sender, EventArgs e) + { + TreeIter iter; + if (listCheck.Selection.GetSelected (out iter)) { + buttonRemove.Sensitive = true; + sqlEditor.Editable = true; + + CheckConstraintSchema check = store.GetValue (iter, colObjIndex) as CheckConstraintSchema; + sqlEditor.Text = check.Source; + } else { + buttonRemove.Sensitive = false; + sqlEditor.Editable = false; + sqlEditor.Text = String.Empty; + } + } + + private void IsColumnConstraintToggled (object sender, ToggledArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + bool val = (bool) store.GetValue (iter, colIsColumnConstraintIndex); + store.SetValue (iter, colIsColumnConstraintIndex, !val); + EmitContentChanged (); + } + } + + private void NameEdited (object sender, EditedArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + if (!string.IsNullOrEmpty (args.NewText)) { + store.SetValue (iter, colNameIndex, args.NewText); + EmitContentChanged (); + } else { + string oldText = store.GetValue (iter, colNameIndex) as string; + (sender as CellRendererText).Text = oldText; + } + } + } + + private void ColumnEdited (object sender, EditedArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + if (columns.Contains (args.NewText)) { //only allow existing columns + store.SetValue (iter, colColumnNameIndex, args.NewText); + EmitContentChanged (); + } else { + string oldText = store.GetValue (iter, colColumnNameIndex) as string; + (sender as CellRendererText).Text = oldText; + } + } + } + + private void SourceChanged (object sender, EventArgs args) + { + TreeIter iter; + if (listCheck.Selection.GetSelected (out iter)) { + CheckConstraintSchema check = store.GetValue (iter, colObjIndex) as CheckConstraintSchema; + check.Source = sqlEditor.Text; + store.SetValue (iter, colSourceIndex, sqlEditor.Text); + EmitContentChanged (); + } + } + + private void AddConstraint (CheckConstraintSchema check) + { + store.AppendValues (check.Name, String.Empty, false, String.Empty, check); + } + + protected virtual void EmitContentChanged () + { + if (ContentChanged != null) + ContentChanged (this, EventArgs.Empty); + } + + public virtual bool ValidateSchemaObjects (out string msg) + { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + string name = store.GetValue (iter, colNameIndex) as string; + string column = store.GetValue (iter, colColumnNameIndex) as string; + string source = store.GetValue (iter, colSourceIndex) as string; + bool iscolc = (bool)store.GetValue (iter, colIsColumnConstraintIndex); + + if (String.IsNullOrEmpty (source)) { + msg = GettextCatalog.GetString ("Checked constraint '{0}' does not contain a check statement.", name); + return false; + } + + if (iscolc && String.IsNullOrEmpty (column)) { + msg = GettextCatalog.GetString ("Checked constraint '{0}' is marked as a column constraint but is not applied to a column.", name); + return false; + } + } while (store.IterNext (ref iter)); + } + msg = null; + return true; + } + + public virtual void FillSchemaObjects () + { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + CheckConstraintSchema check = store.GetValue (iter, colObjIndex) as CheckConstraintSchema; + + check.Name = store.GetValue (iter, colNameIndex) as string; + check.Source = store.GetValue (iter, colSourceIndex) as string; + check.IsColumnConstraint = (bool)store.GetValue (iter, colIsColumnConstraintIndex); + + if (check.IsColumnConstraint) { + string column = store.GetValue (iter, colColumnNameIndex) as string; + check.Columns.Add (columns.Search (column)); + } + + table.Constraints.Add (check); + } while (store.IterNext (ref iter)); + } + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/ColumnsEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/ColumnsEditorWidget.cs new file mode 100644 index 0000000000..260d33a6ae --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/ColumnsEditorWidget.cs @@ -0,0 +1,429 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Gtk; +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.Designer +{ + public partial class ColumnsEditorWidget : Gtk.Bin + { + public event EventHandler ContentChanged; + + private ListStore storeColumns; + private ListStore storeTypes; + + private const int colPKIndex = 0; + private const int colNameIndex = 1; + private const int colTypeIndex = 2; + private const int colLengthIndex = 3; + private const int colNullableIndex = 4; + private const int colCommentIndex = 5; + private const int colObjIndex = 6; + + private ColumnSchemaCollection columns; + private ConstraintSchemaCollection constraints; + private DataTypeSchemaCollection dataTypes; + private ISchemaProvider schemaProvider; + private TableSchema table; + + private SchemaActions action; + + public ColumnsEditorWidget (ISchemaProvider schemaProvider, SchemaActions action) + { + if (schemaProvider == null) + throw new ArgumentNullException ("schemaProvider"); + + this.schemaProvider = schemaProvider; + this.action = action; + + this.Build(); + + storeTypes = new ListStore (typeof (string), typeof (object)); + storeColumns = new ListStore (typeof (bool), typeof (string), typeof (string), typeof (string), typeof (bool), typeof (string), typeof (object)); + treeColumns.Model = storeColumns; + treeColumns.Selection.Changed += new EventHandler (OnSelectionChanged); + + //TODO: cols for scale, precision, ... ? + TreeViewColumn colPK = new TreeViewColumn (); + TreeViewColumn colName = new TreeViewColumn (); + TreeViewColumn colType = new TreeViewColumn (); + TreeViewColumn colLength = new TreeViewColumn (); + TreeViewColumn colNullable = new TreeViewColumn (); + TreeViewColumn colComment = new TreeViewColumn (); + + colPK.Title = GettextCatalog.GetString ("PK"); + colName.Title = GettextCatalog.GetString ("Name"); + colType.Title = GettextCatalog.GetString ("Type"); + colLength.Title = GettextCatalog.GetString ("Length"); + colNullable.Title = GettextCatalog.GetString ("Nullable"); + colComment.Title = GettextCatalog.GetString ("Comment"); + + colType.MinWidth = 120; //request a bigger width + + CellRendererToggle pkRenderer = new CellRendererToggle (); + CellRendererText nameRenderer = new CellRendererText (); + CellRendererCombo typeRenderer = new CellRendererCombo (); + CellRendererText lengthRenderer = new CellRendererText (); + CellRendererToggle nullableRenderer = new CellRendererToggle (); + CellRendererText commentRenderer = new CellRendererText (); + + nameRenderer.Editable = true; + nameRenderer.Edited += new EditedHandler (NameEdited); + + typeRenderer.Model = storeTypes; + typeRenderer.TextColumn = 0; + typeRenderer.Editable = true; + typeRenderer.Edited += new EditedHandler (TypeEdited); + + lengthRenderer.Editable = true; + lengthRenderer.Edited += new EditedHandler (LengthEdited); + + pkRenderer.Activatable = true; + pkRenderer.Toggled += new ToggledHandler (PkToggled); + + nullableRenderer.Activatable = true; + nullableRenderer.Toggled += new ToggledHandler (NullableToggled); + + commentRenderer.Editable = true; + commentRenderer.Edited += new EditedHandler (CommentEdited); + + colPK.PackStart (pkRenderer, true); + colName.PackStart (nameRenderer, true); + colType.PackStart (typeRenderer, true); + colLength.PackStart (lengthRenderer, true); + colNullable.PackStart (nullableRenderer, true); + colComment.PackStart (commentRenderer, true); + + colPK.AddAttribute (pkRenderer, "active", colPKIndex); + colName.AddAttribute (nameRenderer, "text", colNameIndex); + colType.AddAttribute (typeRenderer, "text", colTypeIndex); + colLength.AddAttribute (lengthRenderer, "text", colLengthIndex); + colNullable.AddAttribute (nullableRenderer, "active", colNullableIndex); + colComment.AddAttribute (commentRenderer, "text", colCommentIndex); + + IDbFactory fac = schemaProvider.ConnectionPool.DbFactory; + if (fac.IsCapabilitySupported ("TableColumn", action, ColumnCapabilities.PrimaryKeyConstraint)) + treeColumns.AppendColumn (colPK); + treeColumns.AppendColumn (colName); + treeColumns.AppendColumn (colType); + if (fac.IsCapabilitySupported ("TableColumn", action, ColumnCapabilities.Length)) + treeColumns.AppendColumn (colLength); + if (fac.IsCapabilitySupported ("TableColumn", action, ColumnCapabilities.Nullable)) + treeColumns.AppendColumn (colNullable); + if (fac.IsCapabilitySupported ("TableColumn", action, ColumnCapabilities.Comment)) + treeColumns.AppendColumn (colComment); + + treeColumns.Reorderable = false; + treeColumns.HeadersClickable = false; + treeColumns.HeadersVisible = true; + //Gtk# 2.10:treeColumns.EnableGridLines = TreeViewGridLines.Both; + treeColumns.EnableSearch = false; + + if (action == SchemaActions.Alter) { + buttonAdd.Sensitive = fac.IsCapabilitySupported ("Table", action, TableCapabilities.AppendColumn); + buttonRemove.Sensitive = fac.IsCapabilitySupported ("Table", action, TableCapabilities.RemoveColumn); + buttonUp.Sensitive = fac.IsCapabilitySupported ("Table", action, TableCapabilities.InsertColumn); + } + + ShowAll (); + } + + public void Initialize (TableSchema table, ColumnSchemaCollection columns, ConstraintSchemaCollection constraints, DataTypeSchemaCollection dataTypes) + { + LoggingService.LogDebug ("ColumnsEditorWidget: entering Initialize"); + if (columns == null) + throw new ArgumentNullException ("columns"); + if (constraints == null) + throw new ArgumentNullException ("constraints"); + if (table == null) + throw new ArgumentNullException ("table"); + if (dataTypes == null) + throw new ArgumentNullException ("dataTypes"); + + this.table = table; + this.columns = columns; + this.constraints = constraints; + this.dataTypes = dataTypes; + + foreach (ColumnSchema column in columns) + AppendColumnSchema (column); + + foreach (DataTypeSchema dataType in dataTypes) + storeTypes.AppendValues (dataType.Name, storeTypes); + LoggingService.LogDebug ("ColumnsEditorWidget: exiting Initialize"); + } + + private void AppendColumnSchema (ColumnSchema column) + { + bool pk = column.Constraints.GetConstraint (ConstraintType.PrimaryKey) != null; + storeColumns.AppendValues (pk, column.Name, column.DataType.Name, column.DataType.LengthRange.Default.ToString (), column.IsNullable, column.Comment, column); + } + + protected virtual void AddClicked (object sender, EventArgs e) + { + int index = 1; + string name = null; + do { + name = "column" + index; + index++; + } while (columns.Contains (name)); + + ColumnSchema column = schemaProvider.GetNewColumnSchema (name, table); + + TreeIter iter; + if (storeTypes.GetIterFirst (out iter)) + column.DataTypeName = storeTypes.GetValue (iter, 0) as string; + + columns.Add (column); + AppendColumnSchema (column); + EmitContentChanged (); + } + + protected virtual void RemoveClicked (object sender, EventArgs e) + { + TreeIter iter; + if (treeColumns.Selection.GetSelected (out iter)) { + ColumnSchema column = storeColumns.GetValue (iter, colObjIndex) as ColumnSchema; + + //TODO: also check for attached constraints + + bool result = Services.MessageService.AskQuestion ( + GettextCatalog.GetString ("Are you sure you want to remove column '{0}'", column.Name), + GettextCatalog.GetString ("Remove Column") + ); + + if (result) { + storeColumns.Remove (ref iter); + EmitContentChanged (); + } + } + } + + private void PkToggled (object sender, ToggledArgs args) + { + TreeIter iter; + if (storeColumns.GetIterFromString (out iter, args.Path)) { + bool val = (bool) storeColumns.GetValue (iter, colPKIndex); + storeColumns.SetValue (iter, colPKIndex, !val); + EmitContentChanged (); + } + } + + private void NullableToggled (object sender, ToggledArgs args) + { + TreeIter iter; + if (storeColumns.GetIterFromString (out iter, args.Path)) { + bool val = (bool) storeColumns.GetValue (iter, colNullableIndex); + ColumnSchema column = storeColumns.GetValue (iter, colObjIndex) as ColumnSchema; + storeColumns.SetValue (iter, colNullableIndex, !val); + column.IsNullable = !val; + EmitContentChanged (); + } + } + + private void NameEdited (object sender, EditedArgs args) + { + TreeIter iter; + if (storeColumns.GetIterFromString (out iter, args.Path)) { + if (!string.IsNullOrEmpty (args.NewText)) { + storeColumns.SetValue (iter, colNameIndex, args.NewText); + ColumnSchema column = storeColumns.GetValue (iter, colObjIndex) as ColumnSchema; + column.Name = args.NewText; + EmitContentChanged (); + } else { + string oldText = storeColumns.GetValue (iter, colNameIndex) as string; + (sender as CellRendererText).Text = oldText; + } + } + } + + private void TypeEdited (object sender, EditedArgs args) + { + TreeIter iter; + if (storeColumns.GetIterFromString (out iter, args.Path)) { + if (!string.IsNullOrEmpty (args.NewText)) { + ColumnSchema column = storeColumns.GetValue (iter, colObjIndex) as ColumnSchema; + + int len = int.Parse (storeColumns.GetValue (iter, colLengthIndex) as string); + if (column.DataType.LengthRange.Default == len) { + //change the length if it is still the default length + DataTypeSchema dtNew = schemaProvider.GetDataType (args.NewText); + storeColumns.SetValue (iter, colLengthIndex, dtNew.LengthRange.Default.ToString ()); + } + + storeColumns.SetValue (iter, colTypeIndex, args.NewText); + column.DataTypeName = args.NewText; + EmitContentChanged (); + } else { + string oldText = storeColumns.GetValue (iter, colTypeIndex) as string; + (sender as CellRendererText).Text = oldText; + } + } + } + + private void LengthEdited (object sender, EditedArgs args) + { + TreeIter iter; + if (storeColumns.GetIterFromString (out iter, args.Path)) { + int len; + if (!string.IsNullOrEmpty (args.NewText) && int.TryParse (args.NewText, out len)) { + storeColumns.SetValue (iter, colLengthIndex, args.NewText); + ColumnSchema column = storeColumns.GetValue (iter, colObjIndex) as ColumnSchema; + column.DataType.LengthRange.Default = int.Parse (args.NewText); + EmitContentChanged (); + } else { + string oldText = storeColumns.GetValue (iter, colLengthIndex) as string; + (sender as CellRendererText).Text = oldText; + } + } + } + + private void CommentEdited (object sender, EditedArgs args) + { + TreeIter iter; + if (storeColumns.GetIterFromString (out iter, args.Path)) { + storeColumns.SetValue (iter, colCommentIndex, args.NewText); + ColumnSchema column = storeColumns.GetValue (iter, colObjIndex) as ColumnSchema; + column.Comment = args.NewText; + EmitContentChanged (); + } + } + + protected virtual void DownClicked (object sender, EventArgs e) + { + TreeIter iter; + if (treeColumns.Selection.GetSelected (out iter)) { + TreePath path = storeColumns.GetPath (iter); + int x = path.Indices[0]; + columns.Swap (x, x + 1); + } + } + + protected virtual void UpClicked (object sender, EventArgs e) + { + TreeIter iter; + if (treeColumns.Selection.GetSelected (out iter)) { + TreePath path = storeColumns.GetPath (iter); + int x = path.Indices[0]; + columns.Swap (x, x - 1); + } + } + + private void OnSelectionChanged (object sender, EventArgs e) + { + IDbFactory fac = schemaProvider.ConnectionPool.DbFactory; + //TODO: check Append if "next" is the last row + TreeIter iter; + bool sel = fac.IsCapabilitySupported ("Table", action, TableCapabilities.RemoveColumn); + bool next = fac.IsCapabilitySupported ("Table", action, TableCapabilities.InsertColumn); + bool prev = next; + + if (treeColumns.Selection.GetSelected (out iter)) { + TreePath path = storeColumns.GetPath (iter); + int index = path.Indices[0]; + + sel &= true; + prev &= index > 0; + next &= storeColumns.IterNext (ref iter); + } + + buttonUp.Sensitive = prev; + buttonDown.Sensitive = next; + buttonRemove.Sensitive = sel; + } + + protected virtual void EmitContentChanged () + { + if (ContentChanged != null) + ContentChanged (this, EventArgs.Empty); + } + + public virtual bool ValidateSchemaObjects (out string msg) + { + TreeIter iter; + if (storeColumns.GetIterFirst (out iter)) { + bool isPk = constraints.GetConstraint (ConstraintType.PrimaryKey) != null; + do { + string name = storeColumns.GetValue (iter, colNameIndex) as string; + string type = storeColumns.GetValue (iter, colTypeIndex) as string; + int len = int.Parse (storeColumns.GetValue (iter, colLengthIndex) as string); + if (!isPk) + isPk = (bool)storeColumns.GetValue (iter, colPKIndex); + + DataTypeSchema dt = schemaProvider.GetDataType (type); + if (dt == null) { + msg = GettextCatalog.GetString ("Unknown data type '{0}' applied to column '{1}'.", type, name); + return false; + } + + //TODO: enable when all providers have good datatype info +// if (!dt.LengthRange.IsInRange (len)) { +// msg = GettextCatalog.GetString ("Invalid length for '{0}'.", name); +// return false; +// } + } while (storeColumns.IterNext (ref iter)); + + if (!isPk) { + msg = GettextCatalog.GetString ("Table '{0}' must contain at least one primary key.", table.Name); + return false; + } else { + msg = null; + return true; + } + } + msg = GettextCatalog.GetString ("Table '{0}' must contain at least 1 column.", table.Name); + return false; + } + + public virtual void FillSchemaObjects () + { + TreeIter iter; + if (storeColumns.GetIterFirst (out iter)) { + do { + ColumnSchema column = storeColumns.GetValue (iter, colObjIndex) as ColumnSchema; + + column.Name = storeColumns.GetValue (iter, colNameIndex) as string; + column.DataTypeName = storeColumns.GetValue (iter, colTypeIndex) as string; + column.DataType.LengthRange.Default = int.Parse (storeColumns.GetValue (iter, colLengthIndex) as string); + column.IsNullable = (bool)storeColumns.GetValue (iter, colNullableIndex); + column.Comment = storeColumns.GetValue (iter, colCommentIndex) as string; + + if ((bool)storeColumns.GetValue (iter, colPKIndex)) { + PrimaryKeyConstraintSchema pk = schemaProvider.GetNewPrimaryKeyConstraintSchema ("pk_" + column.Name); + column.Constraints.Add (pk); + } + } while (storeColumns.IterNext (ref iter)); + } + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/CommentEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/CommentEditorWidget.cs new file mode 100644 index 0000000000..738b1ccd5f --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/CommentEditorWidget.cs @@ -0,0 +1,54 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Gtk; +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Database.Sql; + +namespace MonoDevelop.Database.Designer +{ + public partial class CommentEditorWidget : Gtk.Bin + { + public CommentEditorWidget() + { + this.Build(); + } + + public string Comment { + get { return textComment.Buffer.Text; } + set { + if (value == null) + textComment.Buffer.Text = String.Empty; + else + textComment.Buffer.Text = value; + } + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/ConstraintsEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/ConstraintsEditorWidget.cs new file mode 100644 index 0000000000..4dc07ff1c6 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/ConstraintsEditorWidget.cs @@ -0,0 +1,154 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Gtk; +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.Designer +{ + public partial class ConstraintsEditorWidget : Gtk.Bin + { + public event EventHandler ContentChanged; + + private Notebook notebook; + + private ISchemaProvider schemaProvider; + + private PrimaryKeyConstraintEditorWidget pkEditor; + private ForeignKeyConstraintEditorWidget fkEditor; + private CheckConstraintEditorWidget checkEditor; + private UniqueConstraintEditorWidget uniqueEditor; + + private SchemaActions action; + + public ConstraintsEditorWidget (ISchemaProvider schemaProvider, SchemaActions action) + { + if (schemaProvider == null) + throw new ArgumentNullException ("schemaProvider"); + + this.schemaProvider = schemaProvider; + this.action = action; + + //TODO: enable/disable features based on schema provider metadata + + this.Build(); + + notebook = new Notebook (); + Add (notebook); + } + + public void Initialize (TableSchemaCollection tables, TableSchema table, ColumnSchemaCollection columns, ConstraintSchemaCollection constraints, DataTypeSchemaCollection dataTypes) + { + if (columns == null) + throw new ArgumentNullException ("columns"); + if (constraints == null) + throw new ArgumentNullException ("constraints"); + if (table == null) + throw new ArgumentNullException ("table"); + if (tables == null) + throw new ArgumentNullException ("tables"); + + IDbFactory fac = schemaProvider.ConnectionPool.DbFactory; + if (fac.IsCapabilitySupported ("Table", action, TableCapabilities.PrimaryKeyConstraint)) { + //not for column constraints, since they are already editable in the column editor + pkEditor = new PrimaryKeyConstraintEditorWidget (schemaProvider, action, table, columns, constraints); + pkEditor.ContentChanged += new EventHandler (OnContentChanged); + notebook.AppendPage (pkEditor, new Label (GettextCatalog.GetString ("Primary Key"))); + } + + if (fac.IsCapabilitySupported ("Table", action, TableCapabilities.ForeignKeyConstraint) + || fac.IsCapabilitySupported ("TableColumn", action, TableCapabilities.ForeignKeyConstraint)) { + fkEditor = new ForeignKeyConstraintEditorWidget (schemaProvider, action, tables, table, columns, constraints); + fkEditor.ContentChanged += new EventHandler (OnContentChanged); + notebook.AppendPage (fkEditor, new Label (GettextCatalog.GetString ("Foreign Key"))); + } + + if (fac.IsCapabilitySupported ("Table", action, TableCapabilities.CheckConstraint) + || fac.IsCapabilitySupported ("TableColumn", action, TableCapabilities.CheckConstraint)) { + checkEditor = new CheckConstraintEditorWidget (schemaProvider, action, table, columns, constraints); + checkEditor.ContentChanged += new EventHandler (OnContentChanged); + notebook.AppendPage (checkEditor, new Label (GettextCatalog.GetString ("Check"))); + } + + if (fac.IsCapabilitySupported ("Table", action, TableCapabilities.UniqueConstraint) + || fac.IsCapabilitySupported ("TableColumn", action, TableCapabilities.CheckConstraint)) { + uniqueEditor = new UniqueConstraintEditorWidget (schemaProvider, action, table, columns, constraints); + uniqueEditor.ContentChanged += new EventHandler (OnContentChanged); + notebook.AppendPage (uniqueEditor, new Label (GettextCatalog.GetString ("Unique"))); + } + + ShowAll (); + } + + private void OnContentChanged (object sender, EventArgs args) + { + if (ContentChanged != null) + ContentChanged (this, args); + } + + public virtual bool ValidateSchemaObjects (out string msg) + { + msg = null; + bool ret = true; + + if (pkEditor != null) + ret &= pkEditor.ValidateSchemaObjects (out msg); + if (!ret) return ret; + + if (fkEditor != null) + ret &= fkEditor.ValidateSchemaObjects (out msg); + if (!ret) return ret; + + if (checkEditor != null) + ret &= checkEditor.ValidateSchemaObjects (out msg); + if (!ret) return ret; + + if (uniqueEditor != null) + ret &= uniqueEditor.ValidateSchemaObjects (out msg); + if (!ret) return ret; + + return ret; + } + + public virtual void FillSchemaObjects () + { + if (pkEditor != null) + pkEditor.FillSchemaObjects (); + if (fkEditor != null) + fkEditor.FillSchemaObjects (); + if (checkEditor != null) + checkEditor.FillSchemaObjects (); + if (uniqueEditor != null) + uniqueEditor.FillSchemaObjects (); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/ForeignKeyConstraintEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/ForeignKeyConstraintEditorWidget.cs new file mode 100644 index 0000000000..8e8d54ba0c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/ForeignKeyConstraintEditorWidget.cs @@ -0,0 +1,419 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using Gtk; +using System; +using System.Text; +using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Components; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.Designer +{ + public partial class ForeignKeyConstraintEditorWidget : Gtk.Bin + { + public event EventHandler ContentChanged; + + private ISchemaProvider schemaProvider; + private TableSchema table; + private TableSchemaCollection tables; + private ColumnSchemaCollection columns; + private ConstraintSchemaCollection constraints; + + private const int colNameIndex = 0; + private const int colReferenceTableIndex = 1; + private const int colIsColumnConstraintIndex = 2; + private const int colColumnsIndex = 3; + private const int colReferenceColumnsIndex = 4; + private const int colDeleteActionIndex = 5; + private const int colUpdateActionIndex = 6; + private const int colObjIndex = 7; + + private ListStore store; + private ListStore storeActions; + private ListStore storeTables; + + private SchemaActions action; + + //TODO: difference between columns and reference columns + combo events + public ForeignKeyConstraintEditorWidget (ISchemaProvider schemaProvider, SchemaActions action, TableSchemaCollection tables, TableSchema table, ColumnSchemaCollection columns, ConstraintSchemaCollection constraints) + { + if (columns == null) + throw new ArgumentNullException ("columns"); + if (table == null) + throw new ArgumentNullException ("table"); + if (constraints == null) + throw new ArgumentNullException ("constraints"); + if (schemaProvider == null) + throw new ArgumentNullException ("schemaProvider"); + if (tables == null) + throw new ArgumentNullException ("tables"); + + this.schemaProvider = schemaProvider; + this.table = table; + this.tables = tables; + this.columns = columns; + this.constraints = constraints; + this.action = action; + + this.Build(); + + store = new ListStore (typeof (string), typeof (string), typeof (bool), typeof (string), typeof (string), typeof (string), typeof (string), typeof (object)); + listFK.Model = store; + + storeActions = new ListStore (typeof (string), typeof (int)); + storeTables = new ListStore (typeof (string)); + + IDbFactory fac = schemaProvider.ConnectionPool.DbFactory; + if (fac.IsCapabilitySupported ("ForeignKeyConstraint", action, ForeignKeyConstraintCapabilities.Cascade)) + storeActions.AppendValues ("Cascade", ForeignKeyAction.Cascade); + if (fac.IsCapabilitySupported ("ForeignKeyConstraint", action, ForeignKeyConstraintCapabilities.Restrict)) + storeActions.AppendValues ("Restrict", ForeignKeyAction.Restrict); + if (fac.IsCapabilitySupported ("ForeignKeyConstraint", action, ForeignKeyConstraintCapabilities.NoAction)) + storeActions.AppendValues ("No Action", ForeignKeyAction.NoAction); + if (fac.IsCapabilitySupported ("ForeignKeyConstraint", action, ForeignKeyConstraintCapabilities.SetNull)) + storeActions.AppendValues ("Set Null", ForeignKeyAction.SetNull); + if (fac.IsCapabilitySupported ("ForeignKeyConstraint", action, ForeignKeyConstraintCapabilities.SetDefault)) + storeActions.AppendValues ("Set Default", ForeignKeyAction.SetDefault); + + foreach (TableSchema tbl in tables) + if (tbl.Name != table.Name) + storeTables.AppendValues (tbl.Name); + + TreeViewColumn colName = new TreeViewColumn (); + TreeViewColumn colRefTable = new TreeViewColumn (); + TreeViewColumn colIsColumnConstraint = new TreeViewColumn (); + TreeViewColumn colDeleteAction = new TreeViewColumn (); + TreeViewColumn colUpdateAction = new TreeViewColumn (); + + colName.Title = GettextCatalog.GetString ("Name"); + colRefTable.Title = GettextCatalog.GetString ("Reference Table"); + colIsColumnConstraint.Title = GettextCatalog.GetString ("Column Constraint"); + colDeleteAction.Title = GettextCatalog.GetString ("Delete Action"); + colUpdateAction.Title = GettextCatalog.GetString ("Update Action"); + + colRefTable.MinWidth = 120; + + CellRendererText nameRenderer = new CellRendererText (); + CellRendererCombo refTableRenderer = new CellRendererCombo (); + CellRendererToggle isColumnConstraintRenderer = new CellRendererToggle (); + CellRendererCombo deleteActionRenderer = new CellRendererCombo (); + CellRendererCombo updateActionRenderer = new CellRendererCombo (); + + nameRenderer.Editable = true; + nameRenderer.Edited += new EditedHandler (NameEdited); + + refTableRenderer.Model = storeTables; + refTableRenderer.TextColumn = 0; + refTableRenderer.Editable = true; + refTableRenderer.Edited += new EditedHandler (RefTableEdited); + + isColumnConstraintRenderer.Activatable = true; + isColumnConstraintRenderer.Toggled += new ToggledHandler (IsColumnConstraintToggled); + + deleteActionRenderer.Model = storeActions; + deleteActionRenderer.TextColumn = 0; + deleteActionRenderer.Editable = true; + deleteActionRenderer.Edited += new EditedHandler (DeleteActionEdited); + + updateActionRenderer.Model = storeActions; + updateActionRenderer.TextColumn = 0; + updateActionRenderer.Editable = true; + updateActionRenderer.Edited += new EditedHandler (UpdateActionEdited); + + colName.PackStart (nameRenderer, true); + colRefTable.PackStart (refTableRenderer, true); + colIsColumnConstraint.PackStart (isColumnConstraintRenderer, true); + colDeleteAction.PackStart (deleteActionRenderer, true); + colUpdateAction.PackStart (updateActionRenderer, true); + + colName.AddAttribute (nameRenderer, "text", colNameIndex); + colRefTable.AddAttribute (refTableRenderer, "text", colReferenceTableIndex); + colIsColumnConstraint.AddAttribute (isColumnConstraintRenderer, "active", colIsColumnConstraintIndex); + colDeleteAction.AddAttribute (deleteActionRenderer, "text", colDeleteActionIndex); + colUpdateAction.AddAttribute (updateActionRenderer, "text", colUpdateActionIndex); + + listFK.AppendColumn (colName); + listFK.AppendColumn (colRefTable); + listFK.AppendColumn (colIsColumnConstraint); + listFK.AppendColumn (colDeleteAction); + listFK.AppendColumn (colUpdateAction); + + columnSelecter.ColumnToggled += new EventHandler (ColumnToggled); + referenceColumnSelecter.ColumnToggled += new EventHandler (ReferenceColumnToggled); + listFK.Selection.Changed += new EventHandler (SelectionChanged); + + ShowAll (); + } + + protected virtual void AddClicked (object sender, EventArgs e) + { + ForeignKeyConstraintSchema fk = schemaProvider.GetNewForeignKeyConstraintSchema ("fk_new"); + int index = 1; + while (constraints.Contains (fk.Name)) + fk.Name = "fk_new" + (index++); + constraints.Add (fk); + AddConstraint (fk); + EmitContentChanged (); + } + + protected virtual void RemoveClicked (object sender, EventArgs e) + { + TreeIter iter; + if (listFK.Selection.GetSelected (out iter)) { + ForeignKeyConstraintSchema fk = store.GetValue (iter, colObjIndex) as ForeignKeyConstraintSchema; + + if (Services.MessageService.AskQuestion ( + GettextCatalog.GetString ("Are you sure you want to remove constraint '{0}'?", fk.Name), + GettextCatalog.GetString ("Remove Constraint") + )) { + store.Remove (ref iter); + constraints.Remove (fk); + EmitContentChanged (); + } + } + } + + private void SelectionChanged (object sender, EventArgs args) + { + columnSelecter.DeselectAll (); + + TreeIter iter; + if (listFK.Selection.GetSelected (out iter)) { + columnSelecter.Sensitive = true; + SetSelectionFromIter (iter); + } else { + columnSelecter.Sensitive = false; + } + } + + private void SetSelectionFromIter (TreeIter iter) + { + bool iscolc = (bool)store.GetValue (iter, colIsColumnConstraintIndex); + columnSelecter.SingleCheck = iscolc; + + string colstr = store.GetValue (iter, colColumnsIndex) as string; + string[] cols = colstr.Split (','); + foreach (string col in cols) + columnSelecter.Select (col); + + colstr = store.GetValue (iter, colReferenceColumnsIndex) as string; + cols = colstr.Split (','); + foreach (string col in cols) + referenceColumnSelecter.Select (col); + } + + private void RefTableEdited (object sender, EditedArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + if (tables.Contains (args.NewText)) { + store.SetValue (iter, colReferenceTableIndex, args.NewText); + SetSelectionFromIter (iter); + EmitContentChanged (); + } else { + string oldText = store.GetValue (iter, colReferenceTableIndex) as string; + (sender as CellRendererText).Text = oldText; + } + } + } + + private void ColumnToggled (object sender, EventArgs args) + { + TreeIter iter; + if (listFK.Selection.GetSelected (out iter)) { + store.SetValue (iter, colColumnsIndex, GetColumnsString (columnSelecter.CheckedColumns)); + EmitContentChanged (); + } + } + + private void ReferenceColumnToggled (object sender, EventArgs args) + { + TreeIter iter; + if (listFK.Selection.GetSelected (out iter)) { + store.SetValue (iter, colReferenceColumnsIndex, GetColumnsString (referenceColumnSelecter.CheckedColumns)); + EmitContentChanged (); + } + } + + private void IsColumnConstraintToggled (object sender, ToggledArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + bool val = (bool) store.GetValue (iter, colIsColumnConstraintIndex); + store.SetValue (iter, colIsColumnConstraintIndex, !val); + EmitContentChanged (); + } + } + + private void NameEdited (object sender, EditedArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + if (!string.IsNullOrEmpty (args.NewText)) { + store.SetValue (iter, colNameIndex, args.NewText); + EmitContentChanged (); + } else { + string oldText = store.GetValue (iter, colNameIndex) as string; + (sender as CellRendererText).Text = oldText; + } + } + } + + private void UpdateActionEdited (object sender, EditedArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + if (IsValidForeignKeyAction (args.NewText)) { + store.SetValue (iter, colUpdateActionIndex, args.NewText); + EmitContentChanged (); + } else { + string oldText = store.GetValue (iter, colUpdateActionIndex) as string; + (sender as CellRendererText).Text = oldText; + } + } + } + + private void DeleteActionEdited (object sender, EditedArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + if (IsValidForeignKeyAction (args.NewText)) { + store.SetValue (iter, colDeleteActionIndex, args.NewText); + EmitContentChanged (); + } else { + string oldText = store.GetValue (iter, colDeleteActionIndex) as string; + (sender as CellRendererText).Text = oldText; + } + } + } + + private bool IsValidForeignKeyAction (string name) + { + foreach (string item in Enum.GetNames (typeof (ForeignKeyAction))) { + if (item == name) + return true; + } + return false; + } + + private void AddConstraint (ForeignKeyConstraintSchema fk) + { + store.AppendValues (fk.Name, String.Empty, false, String.Empty, String.Empty, + fk.DeleteAction.ToString (), fk.UpdateAction.ToString (), fk + ); + } + + protected virtual void EmitContentChanged () + { + if (ContentChanged != null) + ContentChanged (this, EventArgs.Empty); + } + + public virtual bool ValidateSchemaObjects (out string msg) + { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + string name = store.GetValue (iter, colNameIndex) as string; + string columns = store.GetValue (iter, colColumnsIndex) as string; + + if (String.IsNullOrEmpty (columns)) { + msg = GettextCatalog.GetString ("Unique Key constraint '{0}' must be applied to one or more columns.", name); + return false; + } + } while (store.IterNext (ref iter)); + } + msg = null; + return true; + } + + public virtual void FillSchemaObjects () + { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + ForeignKeyConstraintSchema fk = store.GetValue (iter, colObjIndex) as ForeignKeyConstraintSchema; + + fk.Name = store.GetValue (iter, colNameIndex) as string; + fk.IsColumnConstraint = (bool)store.GetValue (iter, colIsColumnConstraintIndex); + fk.ReferenceTableName = store.GetValue (iter, colReferenceTableIndex) as string; + + fk.DeleteAction = GetForeignKeyAction (iter, colDeleteActionIndex); + fk.UpdateAction = GetForeignKeyAction (iter, colUpdateActionIndex); + + string colstr = store.GetValue (iter, colColumnsIndex) as string; + string[] cols = colstr.Split (','); + foreach (string col in cols) { + ColumnSchema column = columns.Search (col); + fk.Columns.Add (column); + } + + colstr = store.GetValue (iter, colReferenceColumnsIndex) as string; + cols = colstr.Split (','); + foreach (string col in cols) { + ColumnSchema column = columns.Search (col); + fk.ReferenceColumns.Add (column); + } + + table.Constraints.Add (fk); + } while (store.IterNext (ref iter)); + } + } + + private string GetColumnsString (IEnumerable<ColumnSchema> collection) + { + bool first = true; + StringBuilder sb = new StringBuilder (); + foreach (ColumnSchema column in collection) { + if (first) + first = false; + else + sb.Append (','); + + sb.Append (column.Name); + } + return sb.ToString (); + } + + private ForeignKeyAction GetForeignKeyAction (TreeIter colIter, int colIndex) + { + string name = store.GetValue (colIter, colIndex) as string; + + TreeIter iter; + if (storeActions.GetIterFirst (out iter)) { + do { + string actionName = storeActions.GetValue (iter, 0) as string; + if (actionName == name) + return (ForeignKeyAction)storeActions.GetValue (iter, 1); + } while (storeActions.IterNext (ref iter)); + } + return ForeignKeyAction.None; + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/IndicesEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/IndicesEditorWidget.cs new file mode 100644 index 0000000000..5c81ad67fa --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/IndicesEditorWidget.cs @@ -0,0 +1,68 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Gtk; +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.Designer +{ + public partial class IndicesEditorWidget : Gtk.Bin + { + public event EventHandler ContentChanged; + + private ISchemaProvider schemaProvider; + + private SchemaActions action; + + public IndicesEditorWidget(ISchemaProvider schemaProvider, SchemaActions action) + { + if (schemaProvider == null) + throw new ArgumentNullException ("schemaProvider"); + + this.schemaProvider = schemaProvider; + this.action = action; + + this.Build(); + } + + public virtual bool ValidateSchemaObjects (out string msg) + { + msg = null; + return true; + } + + public virtual void FillSchemaObjects () + { + + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/PrimaryKeyConstraintEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/PrimaryKeyConstraintEditorWidget.cs new file mode 100644 index 0000000000..763fea5034 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/PrimaryKeyConstraintEditorWidget.cs @@ -0,0 +1,229 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using Gtk; +using System; +using System.Text; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Components; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.Designer +{ + public partial class PrimaryKeyConstraintEditorWidget : Gtk.Bin + { + public event EventHandler ContentChanged; + + private ISchemaProvider schemaProvider; + private TableSchema table; + private ColumnSchemaCollection columns; + private ConstraintSchemaCollection constraints; + + private SchemaActions action; + + private ListStore store; + + private const int colNameIndex = 0; + private const int colColumnsIndex = 1; + private const int colObjIndex = 2; + + public PrimaryKeyConstraintEditorWidget (ISchemaProvider schemaProvider, SchemaActions action, TableSchema table, ColumnSchemaCollection columns, ConstraintSchemaCollection constraints) + { + if (columns == null) + throw new ArgumentNullException ("columns"); + if (table == null) + throw new ArgumentNullException ("table"); + if (constraints == null) + throw new ArgumentNullException ("constraints"); + if (schemaProvider == null) + throw new ArgumentNullException ("schemaProvider"); + + this.schemaProvider = schemaProvider; + this.table = table; + this.columns = columns; + this.constraints = constraints; + this.action = action; + + this.Build(); + + store = new ListStore (typeof (string), typeof (string), typeof (object)); + listPK.Model = store; + + TreeViewColumn colName = new TreeViewColumn (); + + colName.Title = GettextCatalog.GetString ("Name"); + CellRendererText nameRenderer = new CellRendererText (); + + nameRenderer.Editable = true; + nameRenderer.Edited += new EditedHandler (NameEdited); + + colName.PackStart (nameRenderer, true); + colName.AddAttribute (nameRenderer, "text", colNameIndex); + listPK.AppendColumn (colName); + + columnSelecter.Initialize (columns); + + listPK.Selection.Changed += new EventHandler (SelectionChanged); + columnSelecter.ColumnToggled += new EventHandler (ColumnToggled); + + foreach (PrimaryKeyConstraintSchema pk in constraints.GetConstraints (ConstraintType.PrimaryKey)) + AddConstraint (pk); + + ShowAll (); + } + + private void NameEdited (object sender, EditedArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + if (!string.IsNullOrEmpty (args.NewText) && !constraints.Contains (args.NewText)) { + store.SetValue (iter, colNameIndex, args.NewText); + EmitContentChanged (); + } else { + string oldText = store.GetValue (iter, colNameIndex) as string; + (sender as CellRendererText).Text = oldText; + } + } + } + + private void SelectionChanged (object sender, EventArgs args) + { + columnSelecter.DeselectAll (); + + TreeIter iter; + if (listPK.Selection.GetSelected (out iter)) { + columnSelecter.Sensitive = true; + buttonRemove.Sensitive = true; + + string colstr = store.GetValue (iter, colColumnsIndex) as string; + string[] cols = colstr.Split (','); + foreach (string col in cols) + columnSelecter.Select (col); + } else { + columnSelecter.Sensitive = false; + buttonRemove.Sensitive = false; + } + } + + private void ColumnToggled (object sender, EventArgs args) + { + TreeIter iter; + if (listPK.Selection.GetSelected (out iter)) { + bool first = true; + StringBuilder sb = new StringBuilder (); + foreach (ColumnSchema column in columnSelecter.CheckedColumns) { + if (first) + first = false; + else + sb.Append (','); + + sb.Append (column.Name); + } + + store.SetValue (iter, colColumnsIndex, sb.ToString ()); + EmitContentChanged (); + } + } + + protected virtual void AddClicked (object sender, System.EventArgs e) + { + PrimaryKeyConstraintSchema pk = schemaProvider.GetNewPrimaryKeyConstraintSchema ("pk_new"); + int index = 1; + while (constraints.Contains (pk.Name)) + pk.Name = "pk_new" + (index++); + constraints.Add (pk); + AddConstraint (pk); + EmitContentChanged (); + } + + protected virtual void RemoveClicked (object sender, System.EventArgs e) + { + TreeIter iter; + if (listPK.Selection.GetSelected (out iter)) { + PrimaryKeyConstraintSchema pk = store.GetValue (iter, colObjIndex) as PrimaryKeyConstraintSchema; + + if (Services.MessageService.AskQuestion ( + GettextCatalog.GetString ("Are you sure you want to remove constraint '{0}'?", pk.Name), + GettextCatalog.GetString ("Remove Constraint") + )) { + store.Remove (ref iter); + constraints.Remove (pk); + EmitContentChanged (); + } + } + } + + private void AddConstraint (PrimaryKeyConstraintSchema pk) + { + store.AppendValues (pk.Name, String.Empty, pk); + } + + public virtual bool ValidateSchemaObjects (out string msg) + { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + string name = store.GetValue (iter, colNameIndex) as string; + string columns = store.GetValue (iter, colColumnsIndex) as string; + + if (String.IsNullOrEmpty (columns)) { + msg = GettextCatalog.GetString ("Primary Key constraint '{0}' must be applied to one or more columns.", name); + return false; + } + } while (store.IterNext (ref iter)); + } + msg = null; + return true; + } + + public virtual void FillSchemaObjects () + { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + PrimaryKeyConstraintSchema pk = store.GetValue (iter, colObjIndex) as PrimaryKeyConstraintSchema; + + pk.Name = store.GetValue (iter, colNameIndex) as string; + string colstr = store.GetValue (iter, colColumnsIndex) as string; + string[] cols = colstr.Split (','); + foreach (string col in cols) { + ColumnSchema column = columns.Search (col); + pk.Columns.Add (column); + } + + table.Constraints.Add (pk); + } while (store.IterNext (ref iter)); + } + } + + protected virtual void EmitContentChanged () + { + if (ContentChanged != null) + ContentChanged (this, EventArgs.Empty); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/TriggersEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/TriggersEditorWidget.cs new file mode 100644 index 0000000000..2e1062e4c7 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/TriggersEditorWidget.cs @@ -0,0 +1,381 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Gtk; +using System; +using System.Threading; +using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.Designer +{ + public partial class TriggersEditorWidget : Gtk.Bin + { + public event EventHandler ContentChanged; + + private ISchemaProvider schemaProvider; + private TableSchema table; + private TriggerSchemaCollection triggers; + + private SchemaActions action; + + private ListStore store; + private ListStore storeTypes; + private ListStore storeEvents; + + private const int colNameIndex = 0; + private const int colTypeIndex = 1; + private const int colEventIndex = 2; + private const int colFireTypeIndex = 3; + private const int colPositionIndex = 4; + private const int colActiveIndex = 5; + private const int colCommentIndex = 6; + private const int colSourceIndex = 7; + private const int colObjIndex = 8; + + public TriggersEditorWidget (ISchemaProvider schemaProvider, SchemaActions action) + { + if (schemaProvider == null) + throw new ArgumentNullException ("schemaProvider"); + + this.schemaProvider = schemaProvider; + this.action = action; + + this.Build(); + + sqlEditor.Editable = false; + sqlEditor.TextChanged += new EventHandler (SourceChanged); + + store = new ListStore (typeof (string), typeof (string), typeof (string), typeof (bool), typeof (string), typeof (bool), typeof (string), typeof (string), typeof (object)); + storeTypes = new ListStore (typeof (string)); + storeEvents = new ListStore (typeof (string)); + listTriggers.Model = store; + listTriggers.Selection.Changed += new EventHandler (OnSelectionChanged); + + foreach (string name in Enum.GetNames (typeof (TriggerType))) + storeTypes.AppendValues (name); + foreach (string name in Enum.GetNames (typeof (TriggerEvent))) + storeEvents.AppendValues (name); + + TreeViewColumn colName = new TreeViewColumn (); + TreeViewColumn colType = new TreeViewColumn (); + TreeViewColumn colEvent = new TreeViewColumn (); + TreeViewColumn colFireType = new TreeViewColumn (); + TreeViewColumn colPosition = new TreeViewColumn (); + TreeViewColumn colActive = new TreeViewColumn (); + TreeViewColumn colComment = new TreeViewColumn (); + + colName.Title = GettextCatalog.GetString ("Name"); + colType.Title = GettextCatalog.GetString ("Type"); + colEvent.Title = GettextCatalog.GetString ("Event"); + colFireType.Title = GettextCatalog.GetString ("Each Row"); + colPosition.Title = GettextCatalog.GetString ("Position"); + colActive.Title = GettextCatalog.GetString ("Active"); + colComment.Title = GettextCatalog.GetString ("Comment"); + + colType.MinWidth = 120; + colEvent.MinWidth = 120; + + CellRendererText nameRenderer = new CellRendererText (); + CellRendererCombo typeRenderer = new CellRendererCombo (); + CellRendererCombo eventRenderer = new CellRendererCombo (); + CellRendererToggle fireTypeRenderer = new CellRendererToggle (); + CellRendererText positionRenderer = new CellRendererText (); + CellRendererToggle activeRenderer = new CellRendererToggle (); + CellRendererText commentRenderer = new CellRendererText (); + + nameRenderer.Editable = true; + nameRenderer.Edited += new EditedHandler (NameEdited); + + typeRenderer.Model = storeTypes; + typeRenderer.TextColumn = 0; + typeRenderer.Editable = true; + typeRenderer.Edited += new EditedHandler (TypeEdited); + + eventRenderer.Model = storeEvents; + eventRenderer.TextColumn = 0; + eventRenderer.Editable = true; + eventRenderer.Edited += new EditedHandler (EventEdited); + + fireTypeRenderer.Activatable = true; + fireTypeRenderer.Toggled += new ToggledHandler (FireTypeToggled); + + positionRenderer.Editable = true; + positionRenderer.Edited += new EditedHandler (PositionEdited); + + activeRenderer.Activatable = true; + activeRenderer.Toggled += new ToggledHandler (ActiveToggled); + + commentRenderer.Editable = true; + commentRenderer.Edited += new EditedHandler (CommentEdited); + + colName.PackStart (nameRenderer, true); + colType.PackStart (typeRenderer, true); + colEvent.PackStart (eventRenderer, true); + colFireType.PackStart (fireTypeRenderer, true); + colPosition.PackStart (positionRenderer, true); + colActive.PackStart (activeRenderer, true); + colComment.PackStart (commentRenderer, true); + + colName.AddAttribute (nameRenderer, "text", colNameIndex); + colType.AddAttribute (typeRenderer, "text", colTypeIndex); + colEvent.AddAttribute (eventRenderer, "text", colEventIndex); + colFireType.AddAttribute (fireTypeRenderer, "active", colFireTypeIndex); + colPosition.AddAttribute (positionRenderer, "text", colPositionIndex); + colActive.AddAttribute (activeRenderer, "active", colActiveIndex); + colComment.AddAttribute (commentRenderer, "text", colCommentIndex); + + listTriggers.AppendColumn (colName); + listTriggers.AppendColumn (colType); + listTriggers.AppendColumn (colEvent); + listTriggers.AppendColumn (colFireType); + listTriggers.AppendColumn (colPosition); + listTriggers.AppendColumn (colActive); + listTriggers.AppendColumn (colComment); + + ShowAll (); + } + + public void Initialize (TableSchema table, TriggerSchemaCollection triggers) + { + if (table == null) + throw new ArgumentNullException ("table"); + if (triggers == null) + throw new ArgumentNullException ("triggers"); + + this.table = table; + this.triggers = triggers; + + foreach (TriggerSchema trigger in triggers) + AddTrigger (trigger); + } + + protected virtual void RemoveClicked (object sender, System.EventArgs e) + { + TreeIter iter; + if (listTriggers.Selection.GetSelected (out iter)) { + TriggerSchema trigger = store.GetValue (iter, colObjIndex) as TriggerSchema; + + if (Services.MessageService.AskQuestion ( + GettextCatalog.GetString ("Are you sure you want to remove trigger '{0}'?", trigger.Name), + GettextCatalog.GetString ("Remove Trigger") + )) { + store.Remove (ref iter); + triggers.Remove (trigger); + EmitContentChanged (); + } + } + } + + protected virtual void AddClicked (object sender, EventArgs e) + { + TriggerSchema trigger = schemaProvider.GetNewTriggerSchema ("trigger_" + table.Name); + trigger.TableName = table.Name; + int index = 1; + while (triggers.Contains (trigger.Name)) + trigger.Name = "trigger_" + table.Name + (index++); + triggers.Add (trigger); + AddTrigger (trigger); + EmitContentChanged (); + } + + private void AddTrigger (TriggerSchema trigger) + { + store.AppendValues (trigger.Name, trigger.TriggerType.ToString (), + trigger.TriggerEvent.ToString (), trigger.TriggerFireType == TriggerFireType.ForEachRow, + trigger.Position.ToString (), trigger.IsActive, trigger.Comment, + trigger.Source , trigger); + } + + private void NameEdited (object sender, EditedArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + if (!string.IsNullOrEmpty (args.NewText)) { + store.SetValue (iter, colNameIndex, args.NewText); + } else { + string oldText = store.GetValue (iter, colNameIndex) as string; + (sender as CellRendererText).Text = oldText; + } + } + } + + protected virtual void OnSelectionChanged (object sender, EventArgs e) + { + TreeIter iter; + if (listTriggers.Selection.GetSelected (out iter)) { + buttonRemove.Sensitive = true; + sqlEditor.Editable = true; + + TriggerSchema trigger = store.GetValue (iter, colObjIndex) as TriggerSchema; + + sqlEditor.Text = trigger.Source; + + } else { + buttonRemove.Sensitive = false; + sqlEditor.Editable = false; + sqlEditor.Text = String.Empty; + } + } + + private void SourceChanged (object sender, EventArgs args) + { + TreeIter iter; + if (listTriggers.Selection.GetSelected (out iter)) { + store.SetValue (iter, colSourceIndex, sqlEditor.Text); + EmitContentChanged (); + } + } + + private void TypeEdited (object sender, EditedArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + foreach (string name in Enum.GetNames (typeof (TriggerType))) { + if (args.NewText == name) { + store.SetValue (iter, colTypeIndex, args.NewText); + EmitContentChanged (); + return; + } + } + string oldText = store.GetValue (iter, colTypeIndex) as string; + (sender as CellRendererText).Text = oldText; + } + } + + private void EventEdited (object sender, EditedArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + foreach (string name in Enum.GetNames (typeof (TriggerEvent))) { + if (args.NewText == name) { + store.SetValue (iter, colEventIndex, args.NewText); + EmitContentChanged (); + return; + } + } + string oldText = store.GetValue (iter, colEventIndex) as string; + (sender as CellRendererText).Text = oldText; + } + } + + private void PositionEdited (object sender, EditedArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + int len; + if (!string.IsNullOrEmpty (args.NewText) && int.TryParse (args.NewText, out len)) { + store.SetValue (iter, colPositionIndex, args.NewText); + EmitContentChanged (); + } else { + string oldText = store.GetValue (iter, colPositionIndex) as string; + (sender as CellRendererText).Text = oldText; + } + } + } + + private void FireTypeToggled (object sender, ToggledArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + bool val = (bool) store.GetValue (iter, colFireTypeIndex); + store.SetValue (iter, colFireTypeIndex, !val); + EmitContentChanged (); + } + } + + private void ActiveToggled (object sender, ToggledArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + bool val = (bool) store.GetValue (iter, colActiveIndex); + store.SetValue (iter, colActiveIndex, !val); + EmitContentChanged (); + } + } + + private void CommentEdited (object sender, EditedArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + store.SetValue (iter, colCommentIndex, args.NewText); + EmitContentChanged (); + } + } + + public virtual bool ValidateSchemaObjects (out string msg) + { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + string name = store.GetValue (iter, colNameIndex) as string; + string source = store.GetValue (iter, colSourceIndex) as string; + //type, event, firetype, position and fireType are always valid + + if (String.IsNullOrEmpty (source)) { + msg = GettextCatalog.GetString ("Trigger '{0}' does not contain a trigger statement.", name); + return false; + } + } while (store.IterNext (ref iter)); + } + msg = null; + return true; + } + + public virtual void FillSchemaObjects () + { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + TriggerSchema trigger = store.GetValue (iter, colObjIndex) as TriggerSchema; + + trigger.Name = store.GetValue (iter, colNameIndex) as string; + + trigger.TriggerType = (TriggerType)Enum.Parse (typeof (TriggerType), store.GetValue (iter, colTypeIndex) as string); + trigger.TriggerEvent = (TriggerEvent)Enum.Parse (typeof (TriggerEvent), store.GetValue (iter, colEventIndex) as string); + trigger.TriggerFireType = (TriggerFireType)Enum.Parse (typeof (TriggerFireType), store.GetValue (iter, colFireTypeIndex) as string); + + trigger.Position = int.Parse (store.GetValue (iter, colPositionIndex) as string); + trigger.IsActive = (bool)store.GetValue (iter, colActiveIndex); + + trigger.Comment = store.GetValue (iter, colCommentIndex) as string; + trigger.Source = store.GetValue (iter, colSourceIndex) as string; + + table.Triggers.Add (trigger); + } while (store.IterNext (ref iter)); + } + } + + protected virtual void EmitContentChanged () + { + if (ContentChanged != null) + ContentChanged (this, EventArgs.Empty); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/UniqueConstraintEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/UniqueConstraintEditorWidget.cs new file mode 100644 index 0000000000..ef5c74a749 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/Widgets/UniqueConstraintEditorWidget.cs @@ -0,0 +1,266 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using Gtk; +using System; +using System.Text; +using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Components; +using MonoDevelop.Database.Sql; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.Designer +{ + public partial class UniqueConstraintEditorWidget : Gtk.Bin + { + public event EventHandler ContentChanged; + + private ISchemaProvider schemaProvider; + private ColumnSchemaCollection columns; + private ConstraintSchemaCollection constraints; + private TableSchema table; + + private SchemaActions action; + + private ListStore store; + + private const int colNameIndex = 0; + private const int colIsColumnConstraintIndex = 1; + private const int colColumnsIndex = 2; + private const int colObjIndex = 3; + + public UniqueConstraintEditorWidget (ISchemaProvider schemaProvider, SchemaActions action, TableSchema table, ColumnSchemaCollection columns, ConstraintSchemaCollection constraints) + { + if (columns == null) + throw new ArgumentNullException ("columns"); + if (table == null) + throw new ArgumentNullException ("table"); + if (constraints == null) + throw new ArgumentNullException ("constraints"); + if (schemaProvider == null) + throw new ArgumentNullException ("schemaProvider"); + + this.schemaProvider = schemaProvider; + this.table = table; + this.columns = columns; + this.constraints = constraints; + this.action = action; + + this.Build(); + + store = new ListStore (typeof (string), typeof (bool), typeof (string), typeof (object)); + listUnique.Model = store; + listUnique.Selection.Changed += new EventHandler (SelectionChanged); + columnSelecter.ColumnToggled += new EventHandler (ColumnToggled); + + TreeViewColumn colName = new TreeViewColumn (); + TreeViewColumn colIsColConstraint = new TreeViewColumn (); + + colName.Title = GettextCatalog.GetString ("Name"); + colIsColConstraint.Title = GettextCatalog.GetString ("Column Constraint"); + + CellRendererText nameRenderer = new CellRendererText (); + CellRendererToggle toggleRenderer = new CellRendererToggle (); + + nameRenderer.Editable = true; + nameRenderer.Edited += new EditedHandler (NameEdited); + + toggleRenderer.Activatable = true; + toggleRenderer.Toggled += new ToggledHandler (IsColumnConstraintToggled); + + colName.PackStart (nameRenderer, true); + colIsColConstraint.PackStart (toggleRenderer, true); + + colName.AddAttribute (nameRenderer, "text", colNameIndex); + colIsColConstraint.AddAttribute (toggleRenderer, "active", colIsColumnConstraintIndex); + + listUnique.AppendColumn (colName); + listUnique.AppendColumn (colIsColConstraint); + + columnSelecter.Initialize (columns); + + foreach (UniqueConstraintSchema uni in constraints.GetConstraints (ConstraintType.Unique)) + AddConstraint (uni); + //TODO: also col constraints + + ShowAll (); + } + + private void NameEdited (object sender, EditedArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + if (!string.IsNullOrEmpty (args.NewText) && !constraints.Contains (args.NewText)) { + store.SetValue (iter, colNameIndex, args.NewText); + EmitContentChanged (); + } else { + string oldText = store.GetValue (iter, colNameIndex) as string; + (sender as CellRendererText).Text = oldText; + } + } + } + + private void IsColumnConstraintToggled (object sender, ToggledArgs args) + { + TreeIter iter; + if (store.GetIterFromString (out iter, args.Path)) { + bool val = (bool) store.GetValue (iter, colIsColumnConstraintIndex); + store.SetValue (iter, colIsColumnConstraintIndex, !val); + SetSelectionFromIter (iter); + EmitContentChanged (); + } + } + + private void SelectionChanged (object sender, EventArgs args) + { + columnSelecter.DeselectAll (); + + TreeIter iter; + if (listUnique.Selection.GetSelected (out iter)) { + columnSelecter.Sensitive = true; + SetSelectionFromIter (iter); + } else { + columnSelecter.Sensitive = false; + } + } + + private void SetSelectionFromIter (TreeIter iter) + { + bool iscolc = (bool)store.GetValue (iter, colIsColumnConstraintIndex); + columnSelecter.SingleCheck = iscolc; + + string colstr = store.GetValue (iter, colColumnsIndex) as string; + string[] cols = colstr.Split (','); + foreach (string col in cols) + columnSelecter.Select (col); + } + + private void ColumnToggled (object sender, EventArgs args) + { + TreeIter iter; + if (listUnique.Selection.GetSelected (out iter)) { + store.SetValue (iter, colColumnsIndex, GetColumnsString (columnSelecter.CheckedColumns)); + EmitContentChanged (); + } + } + + protected virtual void AddClicked (object sender, EventArgs e) + { + UniqueConstraintSchema uni = schemaProvider.GetNewUniqueConstraintSchema ("uni_new"); + int index = 1; + while (constraints.Contains (uni.Name)) + uni.Name = "uni_new" + (index++); + constraints.Add (uni); + AddConstraint (uni); + EmitContentChanged (); + } + + protected virtual void RemoveClicked (object sender, EventArgs e) + { + TreeIter iter; + if (listUnique.Selection.GetSelected (out iter)) { + UniqueConstraintSchema uni = store.GetValue (iter, colObjIndex) as UniqueConstraintSchema; + + if (Services.MessageService.AskQuestion ( + GettextCatalog.GetString ("Are you sure you want to remove constraint '{0}'?", uni.Name), + GettextCatalog.GetString ("Remove Constraint") + )) { + store.Remove (ref iter); + constraints.Remove (uni); + EmitContentChanged (); + } + } + } + + private void AddConstraint (UniqueConstraintSchema uni) + { + string colstr = GetColumnsString (uni.Columns); + store.AppendValues (uni.Name, uni.IsColumnConstraint, colstr, uni); + } + + private string GetColumnsString (IEnumerable<ColumnSchema> collection) + { + bool first = true; + StringBuilder sb = new StringBuilder (); + foreach (ColumnSchema column in collection) { + if (first) + first = false; + else + sb.Append (','); + + sb.Append (column.Name); + } + return sb.ToString (); + } + + public virtual bool ValidateSchemaObjects (out string msg) + { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + string name = store.GetValue (iter, colNameIndex) as string; + string columns = store.GetValue (iter, colColumnsIndex) as string; + + if (String.IsNullOrEmpty (columns)) { + msg = GettextCatalog.GetString ("Unique Key constraint '{0}' must be applied to one or more columns.", name); + return false; + } + } while (store.IterNext (ref iter)); + } + msg = null; + return true; + } + + public virtual void FillSchemaObjects () + { + TreeIter iter; + if (store.GetIterFirst (out iter)) { + do { + UniqueConstraintSchema uni = store.GetValue (iter, colObjIndex) as UniqueConstraintSchema; + + uni.Name = store.GetValue (iter, colNameIndex) as string; + uni.IsColumnConstraint = (bool)store.GetValue (iter, colIsColumnConstraintIndex); + + string colstr = store.GetValue (iter, colColumnsIndex) as string; + string[] cols = colstr.Split (','); + foreach (string col in cols) { + ColumnSchema column = columns.Search (col); + uni.Columns.Add (column); + } + + table.Constraints.Add (uni); + } while (store.IterNext (ref iter)); + } + } + + protected virtual void EmitContentChanged () + { + if (ContentChanged != null) + ContentChanged (this, EventArgs.Empty); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.CheckConstraintEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.CheckConstraintEditorWidget.cs new file mode 100644 index 0000000000..a70c0e9cc3 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.CheckConstraintEditorWidget.cs @@ -0,0 +1,136 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Designer { + + + public partial class CheckConstraintEditorWidget { + + private Gtk.VPaned vpaned; + + private Gtk.HBox hbox; + + private Gtk.ScrolledWindow windowCheck; + + private Gtk.TreeView listCheck; + + private Gtk.VButtonBox vbuttonbox; + + private Gtk.Button buttonAdd; + + private Gtk.Button buttonRemove; + + private Gtk.Frame frame; + + private Gtk.Alignment alignment; + + private MonoDevelop.Database.Components.SqlEditorWidget sqlEditor; + + private Gtk.Label GtkLabel2; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Designer.CheckConstraintEditorWidget + Stetic.BinContainer.Attach(this); + this.Name = "MonoDevelop.Database.Designer.CheckConstraintEditorWidget"; + // Container child MonoDevelop.Database.Designer.CheckConstraintEditorWidget.Gtk.Container+ContainerChild + this.vpaned = new Gtk.VPaned(); + this.vpaned.CanFocus = true; + this.vpaned.Name = "vpaned"; + this.vpaned.Position = 189; + // Container child vpaned.Gtk.Paned+PanedChild + this.hbox = new Gtk.HBox(); + this.hbox.Name = "hbox"; + this.hbox.Spacing = 6; + // Container child hbox.Gtk.Box+BoxChild + this.windowCheck = new Gtk.ScrolledWindow(); + this.windowCheck.CanFocus = true; + this.windowCheck.Name = "windowCheck"; + this.windowCheck.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.windowCheck.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.windowCheck.ShadowType = ((Gtk.ShadowType)(1)); + // Container child windowCheck.Gtk.Container+ContainerChild + this.listCheck = new Gtk.TreeView(); + this.listCheck.CanFocus = true; + this.listCheck.Name = "listCheck"; + this.listCheck.HeadersClickable = true; + this.windowCheck.Add(this.listCheck); + this.hbox.Add(this.windowCheck); + Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.hbox[this.windowCheck])); + w2.Position = 0; + // Container child hbox.Gtk.Box+BoxChild + this.vbuttonbox = new Gtk.VButtonBox(); + this.vbuttonbox.Name = "vbuttonbox"; + this.vbuttonbox.Spacing = 6; + this.vbuttonbox.LayoutStyle = ((Gtk.ButtonBoxStyle)(3)); + // Container child vbuttonbox.Gtk.ButtonBox+ButtonBoxChild + this.buttonAdd = new Gtk.Button(); + this.buttonAdd.CanFocus = true; + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.UseStock = true; + this.buttonAdd.UseUnderline = true; + this.buttonAdd.Label = "gtk-add"; + this.vbuttonbox.Add(this.buttonAdd); + Gtk.ButtonBox.ButtonBoxChild w3 = ((Gtk.ButtonBox.ButtonBoxChild)(this.vbuttonbox[this.buttonAdd])); + w3.Expand = false; + w3.Fill = false; + // Container child vbuttonbox.Gtk.ButtonBox+ButtonBoxChild + this.buttonRemove = new Gtk.Button(); + this.buttonRemove.Sensitive = false; + this.buttonRemove.CanFocus = true; + this.buttonRemove.Name = "buttonRemove"; + this.buttonRemove.UseStock = true; + this.buttonRemove.UseUnderline = true; + this.buttonRemove.Label = "gtk-remove"; + this.vbuttonbox.Add(this.buttonRemove); + Gtk.ButtonBox.ButtonBoxChild w4 = ((Gtk.ButtonBox.ButtonBoxChild)(this.vbuttonbox[this.buttonRemove])); + w4.Position = 1; + w4.Expand = false; + w4.Fill = false; + this.hbox.Add(this.vbuttonbox); + Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(this.hbox[this.vbuttonbox])); + w5.Position = 1; + w5.Expand = false; + w5.Fill = false; + this.vpaned.Add(this.hbox); + Gtk.Paned.PanedChild w6 = ((Gtk.Paned.PanedChild)(this.vpaned[this.hbox])); + w6.Resize = false; + // Container child vpaned.Gtk.Paned+PanedChild + this.frame = new Gtk.Frame(); + this.frame.Name = "frame"; + this.frame.ShadowType = ((Gtk.ShadowType)(0)); + this.frame.LabelXalign = 0F; + // Container child frame.Gtk.Container+ContainerChild + this.alignment = new Gtk.Alignment(0F, 0F, 1F, 1F); + this.alignment.Name = "alignment"; + this.alignment.LeftPadding = ((uint)(12)); + // Container child alignment.Gtk.Container+ContainerChild + this.sqlEditor = new MonoDevelop.Database.Components.SqlEditorWidget(); + this.sqlEditor.Events = ((Gdk.EventMask)(256)); + this.sqlEditor.Name = "sqlEditor"; + this.sqlEditor.Editable = false; + this.alignment.Add(this.sqlEditor); + this.frame.Add(this.alignment); + this.GtkLabel2 = new Gtk.Label(); + this.GtkLabel2.Name = "GtkLabel2"; + this.GtkLabel2.LabelProp = Mono.Unix.Catalog.GetString("Check Condition"); + this.GtkLabel2.UseMarkup = true; + this.frame.LabelWidget = this.GtkLabel2; + this.vpaned.Add(this.frame); + this.Add(this.vpaned); + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.Show(); + this.buttonAdd.Clicked += new System.EventHandler(this.AddClicked); + this.buttonRemove.Clicked += new System.EventHandler(this.RemoveClicked); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.ColumnsEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.ColumnsEditorWidget.cs new file mode 100644 index 0000000000..452c1b30fe --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.ColumnsEditorWidget.cs @@ -0,0 +1,148 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Designer { + + + public partial class ColumnsEditorWidget { + + private Gtk.HPaned hpaned; + + private Gtk.VBox vboxLeft; + + private Gtk.ScrolledWindow scrolledwindowLeft; + + private Gtk.TreeView treeColumns; + + private Gtk.HButtonBox hbuttonbox; + + private Gtk.Button buttonAdd; + + private Gtk.Button buttonRemove; + + private Gtk.Button buttonUp; + + private Gtk.Button buttonDown; + + private Gtk.ScrolledWindow scrolledwindowRight; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Designer.ColumnsEditorWidget + Stetic.BinContainer.Attach(this); + this.Name = "MonoDevelop.Database.Designer.ColumnsEditorWidget"; + // Container child MonoDevelop.Database.Designer.ColumnsEditorWidget.Gtk.Container+ContainerChild + this.hpaned = new Gtk.HPaned(); + this.hpaned.CanFocus = true; + this.hpaned.Name = "hpaned"; + this.hpaned.Position = 662; + // Container child hpaned.Gtk.Paned+PanedChild + this.vboxLeft = new Gtk.VBox(); + this.vboxLeft.Name = "vboxLeft"; + this.vboxLeft.Spacing = 6; + // Container child vboxLeft.Gtk.Box+BoxChild + this.scrolledwindowLeft = new Gtk.ScrolledWindow(); + this.scrolledwindowLeft.CanFocus = true; + this.scrolledwindowLeft.Name = "scrolledwindowLeft"; + this.scrolledwindowLeft.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindowLeft.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindowLeft.ShadowType = ((Gtk.ShadowType)(1)); + // Container child scrolledwindowLeft.Gtk.Container+ContainerChild + this.treeColumns = new Gtk.TreeView(); + this.treeColumns.CanFocus = true; + this.treeColumns.Name = "treeColumns"; + this.treeColumns.HeadersClickable = true; + this.scrolledwindowLeft.Add(this.treeColumns); + this.vboxLeft.Add(this.scrolledwindowLeft); + Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.vboxLeft[this.scrolledwindowLeft])); + w2.Position = 0; + // Container child vboxLeft.Gtk.Box+BoxChild + this.hbuttonbox = new Gtk.HButtonBox(); + this.hbuttonbox.Name = "hbuttonbox"; + this.hbuttonbox.Spacing = 6; + this.hbuttonbox.LayoutStyle = ((Gtk.ButtonBoxStyle)(3)); + // Container child hbuttonbox.Gtk.ButtonBox+ButtonBoxChild + this.buttonAdd = new Gtk.Button(); + this.buttonAdd.CanFocus = true; + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.UseStock = true; + this.buttonAdd.UseUnderline = true; + this.buttonAdd.Label = "gtk-add"; + this.hbuttonbox.Add(this.buttonAdd); + Gtk.ButtonBox.ButtonBoxChild w3 = ((Gtk.ButtonBox.ButtonBoxChild)(this.hbuttonbox[this.buttonAdd])); + w3.Expand = false; + w3.Fill = false; + // Container child hbuttonbox.Gtk.ButtonBox+ButtonBoxChild + this.buttonRemove = new Gtk.Button(); + this.buttonRemove.Sensitive = false; + this.buttonRemove.CanFocus = true; + this.buttonRemove.Name = "buttonRemove"; + this.buttonRemove.UseStock = true; + this.buttonRemove.UseUnderline = true; + this.buttonRemove.Label = "gtk-remove"; + this.hbuttonbox.Add(this.buttonRemove); + Gtk.ButtonBox.ButtonBoxChild w4 = ((Gtk.ButtonBox.ButtonBoxChild)(this.hbuttonbox[this.buttonRemove])); + w4.Position = 1; + w4.Expand = false; + w4.Fill = false; + // Container child hbuttonbox.Gtk.ButtonBox+ButtonBoxChild + this.buttonUp = new Gtk.Button(); + this.buttonUp.Sensitive = false; + this.buttonUp.CanFocus = true; + this.buttonUp.Name = "buttonUp"; + this.buttonUp.UseStock = true; + this.buttonUp.UseUnderline = true; + this.buttonUp.Label = "gtk-go-up"; + this.hbuttonbox.Add(this.buttonUp); + Gtk.ButtonBox.ButtonBoxChild w5 = ((Gtk.ButtonBox.ButtonBoxChild)(this.hbuttonbox[this.buttonUp])); + w5.Position = 2; + w5.Expand = false; + w5.Fill = false; + // Container child hbuttonbox.Gtk.ButtonBox+ButtonBoxChild + this.buttonDown = new Gtk.Button(); + this.buttonDown.Sensitive = false; + this.buttonDown.CanFocus = true; + this.buttonDown.Name = "buttonDown"; + this.buttonDown.UseStock = true; + this.buttonDown.UseUnderline = true; + this.buttonDown.Label = "gtk-go-down"; + this.hbuttonbox.Add(this.buttonDown); + Gtk.ButtonBox.ButtonBoxChild w6 = ((Gtk.ButtonBox.ButtonBoxChild)(this.hbuttonbox[this.buttonDown])); + w6.Position = 3; + w6.Expand = false; + w6.Fill = false; + this.vboxLeft.Add(this.hbuttonbox); + Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(this.vboxLeft[this.hbuttonbox])); + w7.Position = 1; + w7.Expand = false; + w7.Fill = false; + this.hpaned.Add(this.vboxLeft); + Gtk.Paned.PanedChild w8 = ((Gtk.Paned.PanedChild)(this.hpaned[this.vboxLeft])); + w8.Resize = false; + // Container child hpaned.Gtk.Paned+PanedChild + this.scrolledwindowRight = new Gtk.ScrolledWindow(); + this.scrolledwindowRight.CanFocus = true; + this.scrolledwindowRight.Name = "scrolledwindowRight"; + this.scrolledwindowRight.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindowRight.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindowRight.ShadowType = ((Gtk.ShadowType)(1)); + this.hpaned.Add(this.scrolledwindowRight); + this.Add(this.hpaned); + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.Show(); + this.buttonAdd.Clicked += new System.EventHandler(this.AddClicked); + this.buttonRemove.Clicked += new System.EventHandler(this.RemoveClicked); + this.buttonUp.Clicked += new System.EventHandler(this.UpClicked); + this.buttonDown.Clicked += new System.EventHandler(this.DownClicked); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.CommentEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.CommentEditorWidget.cs new file mode 100644 index 0000000000..30f365c84a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.CommentEditorWidget.cs @@ -0,0 +1,44 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Designer { + + + public partial class CommentEditorWidget { + + private Gtk.ScrolledWindow scrolledwindow; + + private Gtk.TextView textComment; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Designer.CommentEditorWidget + Stetic.BinContainer.Attach(this); + this.Name = "MonoDevelop.Database.Designer.CommentEditorWidget"; + // Container child MonoDevelop.Database.Designer.CommentEditorWidget.Gtk.Container+ContainerChild + this.scrolledwindow = new Gtk.ScrolledWindow(); + this.scrolledwindow.CanFocus = true; + this.scrolledwindow.Name = "scrolledwindow"; + this.scrolledwindow.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindow.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.scrolledwindow.ShadowType = ((Gtk.ShadowType)(1)); + // Container child scrolledwindow.Gtk.Container+ContainerChild + this.textComment = new Gtk.TextView(); + this.textComment.CanFocus = true; + this.textComment.Name = "textComment"; + this.scrolledwindow.Add(this.textComment); + this.Add(this.scrolledwindow); + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.Show(); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.ConstraintsEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.ConstraintsEditorWidget.cs new file mode 100644 index 0000000000..dcfe1c5ed7 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.ConstraintsEditorWidget.cs @@ -0,0 +1,27 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Designer { + + + public partial class ConstraintsEditorWidget { + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Designer.ConstraintsEditorWidget + Stetic.BinContainer.Attach(this); + this.Name = "MonoDevelop.Database.Designer.ConstraintsEditorWidget"; + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.Show(); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.CreateDatabaseDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.CreateDatabaseDialog.cs new file mode 100644 index 0000000000..6124f7a170 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.CreateDatabaseDialog.cs @@ -0,0 +1,204 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Designer { + + + public partial class CreateDatabaseDialog { + + private Gtk.Table table; + + private Gtk.Button buttonNew; + + private Gtk.Button buttonSelect; + + private MonoDevelop.Database.Components.DatabaseConnectionContextComboBox comboConnections; + + private Gtk.Entry entryDatabase; + + private Gtk.Entry entryName; + + private Gtk.Label label1; + + private Gtk.Label label2; + + private Gtk.Label label3; + + private Gtk.Button buttonCancel; + + private Gtk.Button buttonOk; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Designer.CreateDatabaseDialog + this.Name = "MonoDevelop.Database.Designer.CreateDatabaseDialog"; + this.Title = Mono.Unix.Catalog.GetString("Create Database"); + this.TypeHint = ((Gdk.WindowTypeHint)(1)); + this.WindowPosition = ((Gtk.WindowPosition)(1)); + this.SkipTaskbarHint = true; + this.HasSeparator = false; + // Internal child MonoDevelop.Database.Designer.CreateDatabaseDialog.VBox + Gtk.VBox w1 = this.VBox; + w1.Name = "dialog1_VBox"; + w1.BorderWidth = ((uint)(2)); + // Container child dialog1_VBox.Gtk.Box+BoxChild + this.table = new Gtk.Table(((uint)(3)), ((uint)(3)), false); + this.table.Name = "table"; + this.table.RowSpacing = ((uint)(6)); + this.table.ColumnSpacing = ((uint)(6)); + this.table.BorderWidth = ((uint)(6)); + // Container child table.Gtk.Table+TableChild + this.buttonNew = new Gtk.Button(); + this.buttonNew.CanFocus = true; + this.buttonNew.Name = "buttonNew"; + this.buttonNew.UseStock = true; + this.buttonNew.UseUnderline = true; + this.buttonNew.Label = "gtk-new"; + this.table.Add(this.buttonNew); + Gtk.Table.TableChild w2 = ((Gtk.Table.TableChild)(this.table[this.buttonNew])); + w2.LeftAttach = ((uint)(2)); + w2.RightAttach = ((uint)(3)); + w2.XOptions = ((Gtk.AttachOptions)(4)); + w2.YOptions = ((Gtk.AttachOptions)(4)); + // Container child table.Gtk.Table+TableChild + this.buttonSelect = new Gtk.Button(); + this.buttonSelect.Sensitive = false; + this.buttonSelect.CanFocus = true; + this.buttonSelect.Name = "buttonSelect"; + this.buttonSelect.UseStock = true; + this.buttonSelect.UseUnderline = true; + this.buttonSelect.Label = "gtk-save-as"; + this.table.Add(this.buttonSelect); + Gtk.Table.TableChild w3 = ((Gtk.Table.TableChild)(this.table[this.buttonSelect])); + w3.TopAttach = ((uint)(2)); + w3.BottomAttach = ((uint)(3)); + w3.LeftAttach = ((uint)(2)); + w3.RightAttach = ((uint)(3)); + w3.XOptions = ((Gtk.AttachOptions)(4)); + w3.YOptions = ((Gtk.AttachOptions)(4)); + // Container child table.Gtk.Table+TableChild + this.comboConnections = new MonoDevelop.Database.Components.DatabaseConnectionContextComboBox(); + this.comboConnections.Name = "comboConnections"; + this.table.Add(this.comboConnections); + Gtk.Table.TableChild w4 = ((Gtk.Table.TableChild)(this.table[this.comboConnections])); + w4.LeftAttach = ((uint)(1)); + w4.RightAttach = ((uint)(2)); + w4.YOptions = ((Gtk.AttachOptions)(4)); + // Container child table.Gtk.Table+TableChild + this.entryDatabase = new Gtk.Entry(); + this.entryDatabase.CanFocus = true; + this.entryDatabase.Name = "entryDatabase"; + this.entryDatabase.IsEditable = true; + this.entryDatabase.InvisibleChar = '●'; + this.table.Add(this.entryDatabase); + Gtk.Table.TableChild w5 = ((Gtk.Table.TableChild)(this.table[this.entryDatabase])); + w5.TopAttach = ((uint)(2)); + w5.BottomAttach = ((uint)(3)); + w5.LeftAttach = ((uint)(1)); + w5.RightAttach = ((uint)(2)); + w5.YOptions = ((Gtk.AttachOptions)(4)); + // Container child table.Gtk.Table+TableChild + this.entryName = new Gtk.Entry(); + this.entryName.CanFocus = true; + this.entryName.Name = "entryName"; + this.entryName.IsEditable = true; + this.entryName.InvisibleChar = '●'; + this.table.Add(this.entryName); + Gtk.Table.TableChild w6 = ((Gtk.Table.TableChild)(this.table[this.entryName])); + w6.TopAttach = ((uint)(1)); + w6.BottomAttach = ((uint)(2)); + w6.LeftAttach = ((uint)(1)); + w6.RightAttach = ((uint)(3)); + w6.XOptions = ((Gtk.AttachOptions)(4)); + w6.YOptions = ((Gtk.AttachOptions)(4)); + // Container child table.Gtk.Table+TableChild + this.label1 = new Gtk.Label(); + this.label1.Name = "label1"; + this.label1.Xalign = 0F; + this.label1.LabelProp = Mono.Unix.Catalog.GetString("Name"); + this.table.Add(this.label1); + Gtk.Table.TableChild w7 = ((Gtk.Table.TableChild)(this.table[this.label1])); + w7.TopAttach = ((uint)(1)); + w7.BottomAttach = ((uint)(2)); + w7.XOptions = ((Gtk.AttachOptions)(4)); + w7.YOptions = ((Gtk.AttachOptions)(4)); + // Container child table.Gtk.Table+TableChild + this.label2 = new Gtk.Label(); + this.label2.Name = "label2"; + this.label2.Xalign = 0F; + this.label2.LabelProp = Mono.Unix.Catalog.GetString("Database"); + this.table.Add(this.label2); + Gtk.Table.TableChild w8 = ((Gtk.Table.TableChild)(this.table[this.label2])); + w8.TopAttach = ((uint)(2)); + w8.BottomAttach = ((uint)(3)); + w8.XOptions = ((Gtk.AttachOptions)(4)); + w8.YOptions = ((Gtk.AttachOptions)(4)); + // Container child table.Gtk.Table+TableChild + this.label3 = new Gtk.Label(); + this.label3.Name = "label3"; + this.label3.Xalign = 0F; + this.label3.LabelProp = Mono.Unix.Catalog.GetString("Base Settings"); + this.table.Add(this.label3); + Gtk.Table.TableChild w9 = ((Gtk.Table.TableChild)(this.table[this.label3])); + w9.XOptions = ((Gtk.AttachOptions)(4)); + w9.YOptions = ((Gtk.AttachOptions)(4)); + w1.Add(this.table); + Gtk.Box.BoxChild w10 = ((Gtk.Box.BoxChild)(w1[this.table])); + w10.Position = 0; + w10.Expand = false; + w10.Fill = false; + // Internal child MonoDevelop.Database.Designer.CreateDatabaseDialog.ActionArea + Gtk.HButtonBox w11 = this.ActionArea; + w11.Name = "dialog1_ActionArea"; + w11.Spacing = 6; + w11.BorderWidth = ((uint)(5)); + w11.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonCancel = new Gtk.Button(); + this.buttonCancel.CanDefault = true; + this.buttonCancel.CanFocus = true; + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.UseStock = true; + this.buttonCancel.UseUnderline = true; + this.buttonCancel.Label = "gtk-cancel"; + this.AddActionWidget(this.buttonCancel, -6); + Gtk.ButtonBox.ButtonBoxChild w12 = ((Gtk.ButtonBox.ButtonBoxChild)(w11[this.buttonCancel])); + w12.Expand = false; + w12.Fill = false; + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonOk = new Gtk.Button(); + this.buttonOk.Sensitive = false; + this.buttonOk.CanDefault = true; + this.buttonOk.CanFocus = true; + this.buttonOk.Name = "buttonOk"; + this.buttonOk.UseStock = true; + this.buttonOk.UseUnderline = true; + this.buttonOk.Label = "gtk-ok"; + this.AddActionWidget(this.buttonOk, -5); + Gtk.ButtonBox.ButtonBoxChild w13 = ((Gtk.ButtonBox.ButtonBoxChild)(w11[this.buttonOk])); + w13.Position = 1; + w13.Expand = false; + w13.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.DefaultWidth = 420; + this.DefaultHeight = 191; + this.Show(); + this.entryName.Changed += new System.EventHandler(this.NameChanged); + this.entryDatabase.Changed += new System.EventHandler(this.DatabaseNameChanged); + this.comboConnections.Changed += new System.EventHandler(this.ConnectionChanged); + this.buttonSelect.Clicked += new System.EventHandler(this.SaveAsClicked); + this.buttonNew.Clicked += new System.EventHandler(this.NewClicked); + this.buttonCancel.Clicked += new System.EventHandler(this.CancelClicked); + this.buttonOk.Clicked += new System.EventHandler(this.OkClicked); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.ForeignKeyConstraintEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.ForeignKeyConstraintEditorWidget.cs new file mode 100644 index 0000000000..9c4064fbce --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.ForeignKeyConstraintEditorWidget.cs @@ -0,0 +1,183 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Designer { + + + public partial class ForeignKeyConstraintEditorWidget { + + private Gtk.HPaned hpaned; + + private Gtk.VBox vbox3; + + private Gtk.ScrolledWindow windowPK; + + private Gtk.TreeView listFK; + + private Gtk.HButtonBox hbuttonbox; + + private Gtk.Button buttonAdd; + + private Gtk.Button buttonRemove; + + private Gtk.VBox vboxColumns; + + private Gtk.Frame frame1; + + private Gtk.Alignment GtkAlignment2; + + private MonoDevelop.Database.Components.SelectColumnWidget columnSelecter; + + private Gtk.Label GtkLabel2; + + private Gtk.Frame frame2; + + private Gtk.Alignment GtkAlignment3; + + private MonoDevelop.Database.Components.SelectColumnWidget referenceColumnSelecter; + + private Gtk.Label GtkLabel3; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Designer.ForeignKeyConstraintEditorWidget + Stetic.BinContainer.Attach(this); + this.Name = "MonoDevelop.Database.Designer.ForeignKeyConstraintEditorWidget"; + // Container child MonoDevelop.Database.Designer.ForeignKeyConstraintEditorWidget.Gtk.Container+ContainerChild + this.hpaned = new Gtk.HPaned(); + this.hpaned.CanFocus = true; + this.hpaned.Name = "hpaned"; + this.hpaned.Position = 293; + // Container child hpaned.Gtk.Paned+PanedChild + this.vbox3 = new Gtk.VBox(); + this.vbox3.Name = "vbox3"; + this.vbox3.Spacing = 6; + // Container child vbox3.Gtk.Box+BoxChild + this.windowPK = new Gtk.ScrolledWindow(); + this.windowPK.CanFocus = true; + this.windowPK.Name = "windowPK"; + this.windowPK.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.windowPK.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.windowPK.ShadowType = ((Gtk.ShadowType)(1)); + // Container child windowPK.Gtk.Container+ContainerChild + this.listFK = new Gtk.TreeView(); + this.listFK.CanFocus = true; + this.listFK.Name = "listFK"; + this.listFK.HeadersClickable = true; + this.windowPK.Add(this.listFK); + this.vbox3.Add(this.windowPK); + Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.vbox3[this.windowPK])); + w2.Position = 0; + // Container child vbox3.Gtk.Box+BoxChild + this.hbuttonbox = new Gtk.HButtonBox(); + this.hbuttonbox.Name = "hbuttonbox"; + this.hbuttonbox.Spacing = 6; + this.hbuttonbox.LayoutStyle = ((Gtk.ButtonBoxStyle)(3)); + // Container child hbuttonbox.Gtk.ButtonBox+ButtonBoxChild + this.buttonAdd = new Gtk.Button(); + this.buttonAdd.CanFocus = true; + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.UseStock = true; + this.buttonAdd.UseUnderline = true; + this.buttonAdd.Label = "gtk-add"; + this.hbuttonbox.Add(this.buttonAdd); + Gtk.ButtonBox.ButtonBoxChild w3 = ((Gtk.ButtonBox.ButtonBoxChild)(this.hbuttonbox[this.buttonAdd])); + w3.Expand = false; + w3.Fill = false; + // Container child hbuttonbox.Gtk.ButtonBox+ButtonBoxChild + this.buttonRemove = new Gtk.Button(); + this.buttonRemove.Sensitive = false; + this.buttonRemove.CanFocus = true; + this.buttonRemove.Name = "buttonRemove"; + this.buttonRemove.UseStock = true; + this.buttonRemove.UseUnderline = true; + this.buttonRemove.Label = "gtk-remove"; + this.hbuttonbox.Add(this.buttonRemove); + Gtk.ButtonBox.ButtonBoxChild w4 = ((Gtk.ButtonBox.ButtonBoxChild)(this.hbuttonbox[this.buttonRemove])); + w4.Position = 1; + w4.Expand = false; + w4.Fill = false; + this.vbox3.Add(this.hbuttonbox); + Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(this.vbox3[this.hbuttonbox])); + w5.Position = 1; + w5.Expand = false; + w5.Fill = false; + this.hpaned.Add(this.vbox3); + Gtk.Paned.PanedChild w6 = ((Gtk.Paned.PanedChild)(this.hpaned[this.vbox3])); + w6.Resize = false; + // Container child hpaned.Gtk.Paned+PanedChild + this.vboxColumns = new Gtk.VBox(); + this.vboxColumns.Name = "vboxColumns"; + this.vboxColumns.Spacing = 6; + // Container child vboxColumns.Gtk.Box+BoxChild + this.frame1 = new Gtk.Frame(); + this.frame1.Name = "frame1"; + this.frame1.ShadowType = ((Gtk.ShadowType)(0)); + this.frame1.LabelXalign = 0F; + // Container child frame1.Gtk.Container+ContainerChild + this.GtkAlignment2 = new Gtk.Alignment(0F, 0F, 1F, 1F); + this.GtkAlignment2.Name = "GtkAlignment2"; + this.GtkAlignment2.LeftPadding = ((uint)(12)); + // Container child GtkAlignment2.Gtk.Container+ContainerChild + this.columnSelecter = new MonoDevelop.Database.Components.SelectColumnWidget(); + this.columnSelecter.Sensitive = false; + this.columnSelecter.CanFocus = true; + this.columnSelecter.Name = "columnSelecter"; + this.columnSelecter.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.columnSelecter.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.columnSelecter.ShadowType = ((Gtk.ShadowType)(1)); + this.columnSelecter.SingleCheck = false; + this.GtkAlignment2.Add(this.columnSelecter); + this.frame1.Add(this.GtkAlignment2); + this.GtkLabel2 = new Gtk.Label(); + this.GtkLabel2.Name = "GtkLabel2"; + this.GtkLabel2.LabelProp = Mono.Unix.Catalog.GetString("Columns"); + this.GtkLabel2.UseMarkup = true; + this.frame1.LabelWidget = this.GtkLabel2; + this.vboxColumns.Add(this.frame1); + Gtk.Box.BoxChild w9 = ((Gtk.Box.BoxChild)(this.vboxColumns[this.frame1])); + w9.Position = 0; + // Container child vboxColumns.Gtk.Box+BoxChild + this.frame2 = new Gtk.Frame(); + this.frame2.Name = "frame2"; + this.frame2.ShadowType = ((Gtk.ShadowType)(0)); + this.frame2.LabelXalign = 0F; + // Container child frame2.Gtk.Container+ContainerChild + this.GtkAlignment3 = new Gtk.Alignment(0F, 0F, 1F, 1F); + this.GtkAlignment3.Name = "GtkAlignment3"; + this.GtkAlignment3.LeftPadding = ((uint)(12)); + // Container child GtkAlignment3.Gtk.Container+ContainerChild + this.referenceColumnSelecter = new MonoDevelop.Database.Components.SelectColumnWidget(); + this.referenceColumnSelecter.Sensitive = false; + this.referenceColumnSelecter.CanFocus = true; + this.referenceColumnSelecter.Name = "referenceColumnSelecter"; + this.referenceColumnSelecter.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.referenceColumnSelecter.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.referenceColumnSelecter.ShadowType = ((Gtk.ShadowType)(1)); + this.referenceColumnSelecter.SingleCheck = false; + this.GtkAlignment3.Add(this.referenceColumnSelecter); + this.frame2.Add(this.GtkAlignment3); + this.GtkLabel3 = new Gtk.Label(); + this.GtkLabel3.Name = "GtkLabel3"; + this.GtkLabel3.LabelProp = Mono.Unix.Catalog.GetString("Reference Columns"); + this.GtkLabel3.UseMarkup = true; + this.frame2.LabelWidget = this.GtkLabel3; + this.vboxColumns.Add(this.frame2); + Gtk.Box.BoxChild w12 = ((Gtk.Box.BoxChild)(this.vboxColumns[this.frame2])); + w12.Position = 1; + this.hpaned.Add(this.vboxColumns); + this.Add(this.hpaned); + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.Show(); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.IndicesEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.IndicesEditorWidget.cs new file mode 100644 index 0000000000..1291b19e35 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.IndicesEditorWidget.cs @@ -0,0 +1,27 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Designer { + + + public partial class IndicesEditorWidget { + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Designer.IndicesEditorWidget + Stetic.BinContainer.Attach(this); + this.Name = "MonoDevelop.Database.Designer.IndicesEditorWidget"; + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.Show(); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.PreviewDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.PreviewDialog.cs new file mode 100644 index 0000000000..43bbbcd2fc --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.PreviewDialog.cs @@ -0,0 +1,94 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Designer { + + + public partial class PreviewDialog { + + private Gtk.VBox vboxContent; + + private MonoDevelop.Database.Components.SqlEditorWidget sqlEditor; + + private Gtk.Button buttonCancel; + + private Gtk.Button buttonOk; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Designer.PreviewDialog + this.Name = "MonoDevelop.Database.Designer.PreviewDialog"; + this.Title = Mono.Unix.Catalog.GetString("Preview"); + this.TypeHint = ((Gdk.WindowTypeHint)(1)); + this.WindowPosition = ((Gtk.WindowPosition)(1)); + this.SkipTaskbarHint = true; + this.HasSeparator = false; + // Internal child MonoDevelop.Database.Designer.PreviewDialog.VBox + Gtk.VBox w1 = this.VBox; + w1.Name = "dialog1_VBox"; + w1.BorderWidth = ((uint)(2)); + // Container child dialog1_VBox.Gtk.Box+BoxChild + this.vboxContent = new Gtk.VBox(); + this.vboxContent.Name = "vboxContent"; + this.vboxContent.Spacing = 6; + // Container child vboxContent.Gtk.Box+BoxChild + this.sqlEditor = new MonoDevelop.Database.Components.SqlEditorWidget(); + this.sqlEditor.Events = ((Gdk.EventMask)(256)); + this.sqlEditor.Name = "sqlEditor"; + this.sqlEditor.Editable = false; + this.vboxContent.Add(this.sqlEditor); + Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.vboxContent[this.sqlEditor])); + w2.Position = 0; + w1.Add(this.vboxContent); + Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(w1[this.vboxContent])); + w3.Position = 0; + // Internal child MonoDevelop.Database.Designer.PreviewDialog.ActionArea + Gtk.HButtonBox w4 = this.ActionArea; + w4.Name = "dialog1_ActionArea"; + w4.Spacing = 6; + w4.BorderWidth = ((uint)(5)); + w4.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonCancel = new Gtk.Button(); + this.buttonCancel.CanDefault = true; + this.buttonCancel.CanFocus = true; + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.UseStock = true; + this.buttonCancel.UseUnderline = true; + this.buttonCancel.Label = "gtk-cancel"; + this.AddActionWidget(this.buttonCancel, -6); + Gtk.ButtonBox.ButtonBoxChild w5 = ((Gtk.ButtonBox.ButtonBoxChild)(w4[this.buttonCancel])); + w5.Expand = false; + w5.Fill = false; + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonOk = new Gtk.Button(); + this.buttonOk.Sensitive = false; + this.buttonOk.CanDefault = true; + this.buttonOk.CanFocus = true; + this.buttonOk.Name = "buttonOk"; + this.buttonOk.UseStock = true; + this.buttonOk.UseUnderline = true; + this.buttonOk.Label = "gtk-ok"; + this.AddActionWidget(this.buttonOk, -5); + Gtk.ButtonBox.ButtonBoxChild w6 = ((Gtk.ButtonBox.ButtonBoxChild)(w4[this.buttonOk])); + w6.Position = 1; + w6.Expand = false; + w6.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.DefaultWidth = 528; + this.DefaultHeight = 382; + this.Show(); + this.buttonCancel.Clicked += new System.EventHandler(this.CancelClicked); + this.buttonOk.Clicked += new System.EventHandler(this.OkClicked); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.PrimaryKeyConstraintEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.PrimaryKeyConstraintEditorWidget.cs new file mode 100644 index 0000000000..d5214075b5 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.PrimaryKeyConstraintEditorWidget.cs @@ -0,0 +1,118 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Designer { + + + public partial class PrimaryKeyConstraintEditorWidget { + + private Gtk.HPaned hpaned; + + private Gtk.VBox vbox3; + + private Gtk.ScrolledWindow windowPK; + + private Gtk.TreeView listPK; + + private Gtk.HButtonBox hbuttonbox; + + private Gtk.Button buttonAdd; + + private Gtk.Button buttonRemove; + + private MonoDevelop.Database.Components.SelectColumnWidget columnSelecter; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Designer.PrimaryKeyConstraintEditorWidget + Stetic.BinContainer.Attach(this); + this.Name = "MonoDevelop.Database.Designer.PrimaryKeyConstraintEditorWidget"; + // Container child MonoDevelop.Database.Designer.PrimaryKeyConstraintEditorWidget.Gtk.Container+ContainerChild + this.hpaned = new Gtk.HPaned(); + this.hpaned.CanFocus = true; + this.hpaned.Name = "hpaned"; + this.hpaned.Position = 293; + // Container child hpaned.Gtk.Paned+PanedChild + this.vbox3 = new Gtk.VBox(); + this.vbox3.Name = "vbox3"; + this.vbox3.Spacing = 6; + // Container child vbox3.Gtk.Box+BoxChild + this.windowPK = new Gtk.ScrolledWindow(); + this.windowPK.CanFocus = true; + this.windowPK.Name = "windowPK"; + this.windowPK.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.windowPK.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.windowPK.ShadowType = ((Gtk.ShadowType)(1)); + // Container child windowPK.Gtk.Container+ContainerChild + this.listPK = new Gtk.TreeView(); + this.listPK.CanFocus = true; + this.listPK.Name = "listPK"; + this.listPK.HeadersClickable = true; + this.windowPK.Add(this.listPK); + this.vbox3.Add(this.windowPK); + Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.vbox3[this.windowPK])); + w2.Position = 0; + // Container child vbox3.Gtk.Box+BoxChild + this.hbuttonbox = new Gtk.HButtonBox(); + this.hbuttonbox.Name = "hbuttonbox"; + this.hbuttonbox.Spacing = 6; + this.hbuttonbox.LayoutStyle = ((Gtk.ButtonBoxStyle)(3)); + // Container child hbuttonbox.Gtk.ButtonBox+ButtonBoxChild + this.buttonAdd = new Gtk.Button(); + this.buttonAdd.CanFocus = true; + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.UseStock = true; + this.buttonAdd.UseUnderline = true; + this.buttonAdd.Label = "gtk-add"; + this.hbuttonbox.Add(this.buttonAdd); + Gtk.ButtonBox.ButtonBoxChild w3 = ((Gtk.ButtonBox.ButtonBoxChild)(this.hbuttonbox[this.buttonAdd])); + w3.Expand = false; + w3.Fill = false; + // Container child hbuttonbox.Gtk.ButtonBox+ButtonBoxChild + this.buttonRemove = new Gtk.Button(); + this.buttonRemove.Sensitive = false; + this.buttonRemove.CanFocus = true; + this.buttonRemove.Name = "buttonRemove"; + this.buttonRemove.UseStock = true; + this.buttonRemove.UseUnderline = true; + this.buttonRemove.Label = "gtk-remove"; + this.hbuttonbox.Add(this.buttonRemove); + Gtk.ButtonBox.ButtonBoxChild w4 = ((Gtk.ButtonBox.ButtonBoxChild)(this.hbuttonbox[this.buttonRemove])); + w4.Position = 1; + w4.Expand = false; + w4.Fill = false; + this.vbox3.Add(this.hbuttonbox); + Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(this.vbox3[this.hbuttonbox])); + w5.Position = 1; + w5.Expand = false; + w5.Fill = false; + this.hpaned.Add(this.vbox3); + Gtk.Paned.PanedChild w6 = ((Gtk.Paned.PanedChild)(this.hpaned[this.vbox3])); + w6.Resize = false; + // Container child hpaned.Gtk.Paned+PanedChild + this.columnSelecter = new MonoDevelop.Database.Components.SelectColumnWidget(); + this.columnSelecter.Sensitive = false; + this.columnSelecter.CanFocus = true; + this.columnSelecter.Name = "columnSelecter"; + this.columnSelecter.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.columnSelecter.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.columnSelecter.ShadowType = ((Gtk.ShadowType)(1)); + this.columnSelecter.SingleCheck = false; + this.hpaned.Add(this.columnSelecter); + this.Add(this.hpaned); + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.Show(); + this.buttonAdd.Clicked += new System.EventHandler(this.AddClicked); + this.buttonRemove.Clicked += new System.EventHandler(this.RemoveClicked); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.ProcedureEditorDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.ProcedureEditorDialog.cs new file mode 100644 index 0000000000..32a2b7077c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.ProcedureEditorDialog.cs @@ -0,0 +1,149 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Designer { + + + public partial class ProcedureEditorDialog { + + private Gtk.VBox vboxContent; + + private Gtk.HBox hboxName; + + private Gtk.Label label7; + + private Gtk.Entry entryName; + + private Gtk.HBox hboxWarning; + + private Gtk.Image imageWarning; + + private Gtk.Label labelWarning; + + private Gtk.Button buttonCancel; + + private Gtk.Button buttonOk; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Designer.ProcedureEditorDialog + this.Name = "MonoDevelop.Database.Designer.ProcedureEditorDialog"; + this.WindowPosition = ((Gtk.WindowPosition)(4)); + this.HasSeparator = false; + // Internal child MonoDevelop.Database.Designer.ProcedureEditorDialog.VBox + Gtk.VBox w1 = this.VBox; + w1.Name = "dialog1_VBox"; + w1.BorderWidth = ((uint)(2)); + // Container child dialog1_VBox.Gtk.Box+BoxChild + this.vboxContent = new Gtk.VBox(); + this.vboxContent.Name = "vboxContent"; + this.vboxContent.Spacing = 6; + this.vboxContent.BorderWidth = ((uint)(6)); + // Container child vboxContent.Gtk.Box+BoxChild + this.hboxName = new Gtk.HBox(); + this.hboxName.Name = "hboxName"; + this.hboxName.Spacing = 6; + // Container child hboxName.Gtk.Box+BoxChild + this.label7 = new Gtk.Label(); + this.label7.Name = "label7"; + this.label7.Xalign = 0F; + this.label7.LabelProp = Mono.Unix.Catalog.GetString("Name"); + this.hboxName.Add(this.label7); + Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.hboxName[this.label7])); + w2.Position = 0; + w2.Expand = false; + w2.Fill = false; + // Container child hboxName.Gtk.Box+BoxChild + this.entryName = new Gtk.Entry(); + this.entryName.CanFocus = true; + this.entryName.Name = "entryName"; + this.entryName.IsEditable = true; + this.entryName.InvisibleChar = '●'; + this.hboxName.Add(this.entryName); + Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.hboxName[this.entryName])); + w3.Position = 1; + this.vboxContent.Add(this.hboxName); + Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.vboxContent[this.hboxName])); + w4.Position = 0; + w4.Expand = false; + w4.Fill = false; + // Container child vboxContent.Gtk.Box+BoxChild + this.hboxWarning = new Gtk.HBox(); + this.hboxWarning.Name = "hboxWarning"; + this.hboxWarning.Spacing = 6; + // Container child hboxWarning.Gtk.Box+BoxChild + this.imageWarning = new Gtk.Image(); + this.imageWarning.Name = "imageWarning"; + this.imageWarning.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-dialog-warning", Gtk.IconSize.Menu, 16); + this.hboxWarning.Add(this.imageWarning); + Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(this.hboxWarning[this.imageWarning])); + w5.Position = 0; + w5.Expand = false; + w5.Fill = false; + // Container child hboxWarning.Gtk.Box+BoxChild + this.labelWarning = new Gtk.Label(); + this.labelWarning.Name = "labelWarning"; + this.labelWarning.Xalign = 0F; + this.labelWarning.LabelProp = ""; + this.hboxWarning.Add(this.labelWarning); + Gtk.Box.BoxChild w6 = ((Gtk.Box.BoxChild)(this.hboxWarning[this.labelWarning])); + w6.Position = 1; + this.vboxContent.Add(this.hboxWarning); + Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(this.vboxContent[this.hboxWarning])); + w7.Position = 2; + w7.Expand = false; + w7.Fill = false; + w1.Add(this.vboxContent); + Gtk.Box.BoxChild w8 = ((Gtk.Box.BoxChild)(w1[this.vboxContent])); + w8.Position = 0; + // Internal child MonoDevelop.Database.Designer.ProcedureEditorDialog.ActionArea + Gtk.HButtonBox w9 = this.ActionArea; + w9.Name = "dialog1_ActionArea"; + w9.Spacing = 6; + w9.BorderWidth = ((uint)(5)); + w9.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonCancel = new Gtk.Button(); + this.buttonCancel.CanDefault = true; + this.buttonCancel.CanFocus = true; + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.UseStock = true; + this.buttonCancel.UseUnderline = true; + this.buttonCancel.Label = "gtk-cancel"; + this.AddActionWidget(this.buttonCancel, -6); + Gtk.ButtonBox.ButtonBoxChild w10 = ((Gtk.ButtonBox.ButtonBoxChild)(w9[this.buttonCancel])); + w10.Expand = false; + w10.Fill = false; + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonOk = new Gtk.Button(); + this.buttonOk.Sensitive = false; + this.buttonOk.CanDefault = true; + this.buttonOk.CanFocus = true; + this.buttonOk.Name = "buttonOk"; + this.buttonOk.UseStock = true; + this.buttonOk.UseUnderline = true; + this.buttonOk.Label = "gtk-ok"; + this.AddActionWidget(this.buttonOk, -5); + Gtk.ButtonBox.ButtonBoxChild w11 = ((Gtk.ButtonBox.ButtonBoxChild)(w9[this.buttonOk])); + w11.Position = 1; + w11.Expand = false; + w11.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.DefaultWidth = 640; + this.DefaultHeight = 480; + this.Show(); + this.entryName.Changed += new System.EventHandler(this.NameChanged); + this.buttonCancel.Clicked += new System.EventHandler(this.CancelClicked); + this.buttonOk.Clicked += new System.EventHandler(this.OkClicked); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.TableEditorDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.TableEditorDialog.cs new file mode 100644 index 0000000000..ff2e5cac41 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.TableEditorDialog.cs @@ -0,0 +1,169 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Designer { + + + public partial class TableEditorDialog { + + private Gtk.VBox vboxContent; + + private Gtk.HBox hboxName; + + private Gtk.Label label7; + + private Gtk.Entry entryName; + + private Gtk.HBox hboxWarning; + + private Gtk.Image imageWarning; + + private Gtk.Label labelWarning; + + private Gtk.CheckButton checkPreview; + + private Gtk.Button buttonCancel; + + private Gtk.Button buttonOk; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Designer.TableEditorDialog + this.Name = "MonoDevelop.Database.Designer.TableEditorDialog"; + this.Title = Mono.Unix.Catalog.GetString("Edit Table"); + this.TypeHint = ((Gdk.WindowTypeHint)(1)); + this.WindowPosition = ((Gtk.WindowPosition)(1)); + this.SkipTaskbarHint = true; + this.HasSeparator = false; + // Internal child MonoDevelop.Database.Designer.TableEditorDialog.VBox + Gtk.VBox w1 = this.VBox; + w1.Name = "dialog1_VBox"; + w1.BorderWidth = ((uint)(2)); + // Container child dialog1_VBox.Gtk.Box+BoxChild + this.vboxContent = new Gtk.VBox(); + this.vboxContent.Name = "vboxContent"; + this.vboxContent.Spacing = 6; + this.vboxContent.BorderWidth = ((uint)(6)); + // Container child vboxContent.Gtk.Box+BoxChild + this.hboxName = new Gtk.HBox(); + this.hboxName.Name = "hboxName"; + this.hboxName.Spacing = 6; + // Container child hboxName.Gtk.Box+BoxChild + this.label7 = new Gtk.Label(); + this.label7.Name = "label7"; + this.label7.Xalign = 0F; + this.label7.LabelProp = Mono.Unix.Catalog.GetString("Name"); + this.hboxName.Add(this.label7); + Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.hboxName[this.label7])); + w2.Position = 0; + w2.Expand = false; + w2.Fill = false; + // Container child hboxName.Gtk.Box+BoxChild + this.entryName = new Gtk.Entry(); + this.entryName.CanFocus = true; + this.entryName.Name = "entryName"; + this.entryName.IsEditable = true; + this.entryName.InvisibleChar = '●'; + this.hboxName.Add(this.entryName); + Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.hboxName[this.entryName])); + w3.Position = 1; + this.vboxContent.Add(this.hboxName); + Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.vboxContent[this.hboxName])); + w4.Position = 0; + w4.Expand = false; + w4.Fill = false; + // Container child vboxContent.Gtk.Box+BoxChild + this.hboxWarning = new Gtk.HBox(); + this.hboxWarning.Name = "hboxWarning"; + this.hboxWarning.Spacing = 6; + // Container child hboxWarning.Gtk.Box+BoxChild + this.imageWarning = new Gtk.Image(); + this.imageWarning.Name = "imageWarning"; + this.imageWarning.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-dialog-warning", Gtk.IconSize.Menu, 16); + this.hboxWarning.Add(this.imageWarning); + Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(this.hboxWarning[this.imageWarning])); + w5.Position = 0; + w5.Expand = false; + w5.Fill = false; + // Container child hboxWarning.Gtk.Box+BoxChild + this.labelWarning = new Gtk.Label(); + this.labelWarning.Name = "labelWarning"; + this.labelWarning.Xalign = 0F; + this.labelWarning.LabelProp = ""; + this.hboxWarning.Add(this.labelWarning); + Gtk.Box.BoxChild w6 = ((Gtk.Box.BoxChild)(this.hboxWarning[this.labelWarning])); + w6.Position = 1; + this.vboxContent.Add(this.hboxWarning); + Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(this.vboxContent[this.hboxWarning])); + w7.PackType = ((Gtk.PackType)(1)); + w7.Position = 2; + w7.Expand = false; + w7.Fill = false; + // Container child vboxContent.Gtk.Box+BoxChild + this.checkPreview = new Gtk.CheckButton(); + this.checkPreview.CanFocus = true; + this.checkPreview.Name = "checkPreview"; + this.checkPreview.Label = Mono.Unix.Catalog.GetString("Preview SQL"); + this.checkPreview.Active = true; + this.checkPreview.DrawIndicator = true; + this.checkPreview.UseUnderline = true; + this.vboxContent.Add(this.checkPreview); + Gtk.Box.BoxChild w8 = ((Gtk.Box.BoxChild)(this.vboxContent[this.checkPreview])); + w8.PackType = ((Gtk.PackType)(1)); + w8.Position = 3; + w8.Expand = false; + w8.Fill = false; + w1.Add(this.vboxContent); + Gtk.Box.BoxChild w9 = ((Gtk.Box.BoxChild)(w1[this.vboxContent])); + w9.Position = 0; + // Internal child MonoDevelop.Database.Designer.TableEditorDialog.ActionArea + Gtk.HButtonBox w10 = this.ActionArea; + w10.Name = "dialog1_ActionArea"; + w10.Spacing = 6; + w10.BorderWidth = ((uint)(5)); + w10.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonCancel = new Gtk.Button(); + this.buttonCancel.CanDefault = true; + this.buttonCancel.CanFocus = true; + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.UseStock = true; + this.buttonCancel.UseUnderline = true; + this.buttonCancel.Label = "gtk-cancel"; + this.AddActionWidget(this.buttonCancel, -6); + Gtk.ButtonBox.ButtonBoxChild w11 = ((Gtk.ButtonBox.ButtonBoxChild)(w10[this.buttonCancel])); + w11.Expand = false; + w11.Fill = false; + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonOk = new Gtk.Button(); + this.buttonOk.Sensitive = false; + this.buttonOk.CanDefault = true; + this.buttonOk.CanFocus = true; + this.buttonOk.Name = "buttonOk"; + this.buttonOk.UseStock = true; + this.buttonOk.UseUnderline = true; + this.buttonOk.Label = "gtk-ok"; + this.AddActionWidget(this.buttonOk, -5); + Gtk.ButtonBox.ButtonBoxChild w12 = ((Gtk.ButtonBox.ButtonBoxChild)(w10[this.buttonOk])); + w12.Position = 1; + w12.Expand = false; + w12.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.DefaultWidth = 640; + this.DefaultHeight = 480; + this.Show(); + this.entryName.Changed += new System.EventHandler(this.NameChanged); + this.buttonCancel.Clicked += new System.EventHandler(this.CancelClicked); + this.buttonOk.Clicked += new System.EventHandler(this.OkClicked); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.TriggersEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.TriggersEditorWidget.cs new file mode 100644 index 0000000000..8afe2f02e8 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.TriggersEditorWidget.cs @@ -0,0 +1,137 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Designer { + + + public partial class TriggersEditorWidget { + + private Gtk.VPaned vpaned; + + private Gtk.HBox hbox; + + private Gtk.ScrolledWindow windowTriggers; + + private Gtk.TreeView listTriggers; + + private Gtk.VButtonBox vbuttonbox; + + private Gtk.Button buttonAdd; + + private Gtk.Button buttonRemove; + + private Gtk.Frame frame; + + private Gtk.Alignment alignment; + + private MonoDevelop.Database.Components.SqlEditorWidget sqlEditor; + + private Gtk.Label GtkLabel2; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Designer.TriggersEditorWidget + Stetic.BinContainer.Attach(this); + this.Name = "MonoDevelop.Database.Designer.TriggersEditorWidget"; + // Container child MonoDevelop.Database.Designer.TriggersEditorWidget.Gtk.Container+ContainerChild + this.vpaned = new Gtk.VPaned(); + this.vpaned.CanFocus = true; + this.vpaned.Name = "vpaned"; + this.vpaned.Position = 205; + // Container child vpaned.Gtk.Paned+PanedChild + this.hbox = new Gtk.HBox(); + this.hbox.Name = "hbox"; + this.hbox.Spacing = 6; + // Container child hbox.Gtk.Box+BoxChild + this.windowTriggers = new Gtk.ScrolledWindow(); + this.windowTriggers.CanFocus = true; + this.windowTriggers.Name = "windowTriggers"; + this.windowTriggers.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.windowTriggers.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.windowTriggers.ShadowType = ((Gtk.ShadowType)(1)); + // Container child windowTriggers.Gtk.Container+ContainerChild + this.listTriggers = new Gtk.TreeView(); + this.listTriggers.CanFocus = true; + this.listTriggers.Name = "listTriggers"; + this.listTriggers.HeadersClickable = true; + this.windowTriggers.Add(this.listTriggers); + this.hbox.Add(this.windowTriggers); + Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.hbox[this.windowTriggers])); + w2.Position = 0; + // Container child hbox.Gtk.Box+BoxChild + this.vbuttonbox = new Gtk.VButtonBox(); + this.vbuttonbox.Name = "vbuttonbox"; + this.vbuttonbox.Spacing = 6; + this.vbuttonbox.LayoutStyle = ((Gtk.ButtonBoxStyle)(3)); + // Container child vbuttonbox.Gtk.ButtonBox+ButtonBoxChild + this.buttonAdd = new Gtk.Button(); + this.buttonAdd.CanFocus = true; + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.UseStock = true; + this.buttonAdd.UseUnderline = true; + this.buttonAdd.Label = "gtk-add"; + this.vbuttonbox.Add(this.buttonAdd); + Gtk.ButtonBox.ButtonBoxChild w3 = ((Gtk.ButtonBox.ButtonBoxChild)(this.vbuttonbox[this.buttonAdd])); + w3.Expand = false; + w3.Fill = false; + // Container child vbuttonbox.Gtk.ButtonBox+ButtonBoxChild + this.buttonRemove = new Gtk.Button(); + this.buttonRemove.Sensitive = false; + this.buttonRemove.CanFocus = true; + this.buttonRemove.Name = "buttonRemove"; + this.buttonRemove.UseStock = true; + this.buttonRemove.UseUnderline = true; + this.buttonRemove.Label = "gtk-remove"; + this.vbuttonbox.Add(this.buttonRemove); + Gtk.ButtonBox.ButtonBoxChild w4 = ((Gtk.ButtonBox.ButtonBoxChild)(this.vbuttonbox[this.buttonRemove])); + w4.Position = 1; + w4.Expand = false; + w4.Fill = false; + this.hbox.Add(this.vbuttonbox); + Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(this.hbox[this.vbuttonbox])); + w5.Position = 1; + w5.Expand = false; + w5.Fill = false; + this.vpaned.Add(this.hbox); + Gtk.Paned.PanedChild w6 = ((Gtk.Paned.PanedChild)(this.vpaned[this.hbox])); + w6.Resize = false; + // Container child vpaned.Gtk.Paned+PanedChild + this.frame = new Gtk.Frame(); + this.frame.Name = "frame"; + this.frame.ShadowType = ((Gtk.ShadowType)(0)); + this.frame.LabelXalign = 0F; + // Container child frame.Gtk.Container+ContainerChild + this.alignment = new Gtk.Alignment(0F, 0F, 1F, 1F); + this.alignment.Name = "alignment"; + this.alignment.LeftPadding = ((uint)(12)); + // Container child alignment.Gtk.Container+ContainerChild + this.sqlEditor = new MonoDevelop.Database.Components.SqlEditorWidget(); + this.sqlEditor.HeightRequest = 80; + this.sqlEditor.Events = ((Gdk.EventMask)(256)); + this.sqlEditor.Name = "sqlEditor"; + this.sqlEditor.Editable = false; + this.alignment.Add(this.sqlEditor); + this.frame.Add(this.alignment); + this.GtkLabel2 = new Gtk.Label(); + this.GtkLabel2.Name = "GtkLabel2"; + this.GtkLabel2.LabelProp = Mono.Unix.Catalog.GetString("Statement"); + this.GtkLabel2.UseMarkup = true; + this.frame.LabelWidget = this.GtkLabel2; + this.vpaned.Add(this.frame); + this.Add(this.vpaned); + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.Show(); + this.buttonAdd.Clicked += new System.EventHandler(this.AddClicked); + this.buttonRemove.Clicked += new System.EventHandler(this.RemoveClicked); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.UniqueConstraintEditorWidget.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.UniqueConstraintEditorWidget.cs new file mode 100644 index 0000000000..2f9d465933 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.UniqueConstraintEditorWidget.cs @@ -0,0 +1,118 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Designer { + + + public partial class UniqueConstraintEditorWidget { + + private Gtk.HPaned hpaned; + + private Gtk.VBox vbox3; + + private Gtk.ScrolledWindow windowPK; + + private Gtk.TreeView listUnique; + + private Gtk.HButtonBox hbuttonbox; + + private Gtk.Button buttonAdd; + + private Gtk.Button buttonRemove; + + private MonoDevelop.Database.Components.SelectColumnWidget columnSelecter; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Designer.UniqueConstraintEditorWidget + Stetic.BinContainer.Attach(this); + this.Name = "MonoDevelop.Database.Designer.UniqueConstraintEditorWidget"; + // Container child MonoDevelop.Database.Designer.UniqueConstraintEditorWidget.Gtk.Container+ContainerChild + this.hpaned = new Gtk.HPaned(); + this.hpaned.CanFocus = true; + this.hpaned.Name = "hpaned"; + this.hpaned.Position = 304; + // Container child hpaned.Gtk.Paned+PanedChild + this.vbox3 = new Gtk.VBox(); + this.vbox3.Name = "vbox3"; + this.vbox3.Spacing = 6; + // Container child vbox3.Gtk.Box+BoxChild + this.windowPK = new Gtk.ScrolledWindow(); + this.windowPK.CanFocus = true; + this.windowPK.Name = "windowPK"; + this.windowPK.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.windowPK.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.windowPK.ShadowType = ((Gtk.ShadowType)(1)); + // Container child windowPK.Gtk.Container+ContainerChild + this.listUnique = new Gtk.TreeView(); + this.listUnique.CanFocus = true; + this.listUnique.Name = "listUnique"; + this.listUnique.HeadersClickable = true; + this.windowPK.Add(this.listUnique); + this.vbox3.Add(this.windowPK); + Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.vbox3[this.windowPK])); + w2.Position = 0; + // Container child vbox3.Gtk.Box+BoxChild + this.hbuttonbox = new Gtk.HButtonBox(); + this.hbuttonbox.Name = "hbuttonbox"; + this.hbuttonbox.Spacing = 6; + this.hbuttonbox.LayoutStyle = ((Gtk.ButtonBoxStyle)(3)); + // Container child hbuttonbox.Gtk.ButtonBox+ButtonBoxChild + this.buttonAdd = new Gtk.Button(); + this.buttonAdd.CanFocus = true; + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.UseStock = true; + this.buttonAdd.UseUnderline = true; + this.buttonAdd.Label = "gtk-add"; + this.hbuttonbox.Add(this.buttonAdd); + Gtk.ButtonBox.ButtonBoxChild w3 = ((Gtk.ButtonBox.ButtonBoxChild)(this.hbuttonbox[this.buttonAdd])); + w3.Expand = false; + w3.Fill = false; + // Container child hbuttonbox.Gtk.ButtonBox+ButtonBoxChild + this.buttonRemove = new Gtk.Button(); + this.buttonRemove.Sensitive = false; + this.buttonRemove.CanFocus = true; + this.buttonRemove.Name = "buttonRemove"; + this.buttonRemove.UseStock = true; + this.buttonRemove.UseUnderline = true; + this.buttonRemove.Label = "gtk-remove"; + this.hbuttonbox.Add(this.buttonRemove); + Gtk.ButtonBox.ButtonBoxChild w4 = ((Gtk.ButtonBox.ButtonBoxChild)(this.hbuttonbox[this.buttonRemove])); + w4.Position = 1; + w4.Expand = false; + w4.Fill = false; + this.vbox3.Add(this.hbuttonbox); + Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(this.vbox3[this.hbuttonbox])); + w5.Position = 1; + w5.Expand = false; + w5.Fill = false; + this.hpaned.Add(this.vbox3); + Gtk.Paned.PanedChild w6 = ((Gtk.Paned.PanedChild)(this.hpaned[this.vbox3])); + w6.Resize = false; + // Container child hpaned.Gtk.Paned+PanedChild + this.columnSelecter = new MonoDevelop.Database.Components.SelectColumnWidget(); + this.columnSelecter.Sensitive = false; + this.columnSelecter.CanFocus = true; + this.columnSelecter.Name = "columnSelecter"; + this.columnSelecter.VscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.columnSelecter.HscrollbarPolicy = ((Gtk.PolicyType)(1)); + this.columnSelecter.ShadowType = ((Gtk.ShadowType)(1)); + this.columnSelecter.SingleCheck = false; + this.hpaned.Add(this.columnSelecter); + this.Add(this.hpaned); + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.Show(); + this.buttonAdd.Clicked += new System.EventHandler(this.AddClicked); + this.buttonRemove.Clicked += new System.EventHandler(this.RemoveClicked); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.UserEditorDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.UserEditorDialog.cs new file mode 100644 index 0000000000..8b6d1c27c9 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.UserEditorDialog.cs @@ -0,0 +1,117 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Designer { + + + public partial class UserEditorDialog { + + private Gtk.VBox vboxContent; + + private Gtk.HBox hboxName; + + private Gtk.Label label7; + + private Gtk.Entry entryName; + + private Gtk.Button buttonCancel; + + private Gtk.Button buttonOk; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Designer.UserEditorDialog + this.Name = "MonoDevelop.Database.Designer.UserEditorDialog"; + this.WindowPosition = ((Gtk.WindowPosition)(4)); + this.HasSeparator = false; + // Internal child MonoDevelop.Database.Designer.UserEditorDialog.VBox + Gtk.VBox w1 = this.VBox; + w1.Name = "dialog1_VBox"; + w1.BorderWidth = ((uint)(2)); + // Container child dialog1_VBox.Gtk.Box+BoxChild + this.vboxContent = new Gtk.VBox(); + this.vboxContent.Name = "vboxContent"; + this.vboxContent.Spacing = 6; + this.vboxContent.BorderWidth = ((uint)(6)); + // Container child vboxContent.Gtk.Box+BoxChild + this.hboxName = new Gtk.HBox(); + this.hboxName.Name = "hboxName"; + this.hboxName.Spacing = 6; + // Container child hboxName.Gtk.Box+BoxChild + this.label7 = new Gtk.Label(); + this.label7.Name = "label7"; + this.label7.Xalign = 0F; + this.label7.LabelProp = Mono.Unix.Catalog.GetString("Name"); + this.hboxName.Add(this.label7); + Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.hboxName[this.label7])); + w2.Position = 0; + w2.Expand = false; + w2.Fill = false; + // Container child hboxName.Gtk.Box+BoxChild + this.entryName = new Gtk.Entry(); + this.entryName.CanFocus = true; + this.entryName.Name = "entryName"; + this.entryName.IsEditable = true; + this.entryName.InvisibleChar = '●'; + this.hboxName.Add(this.entryName); + Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.hboxName[this.entryName])); + w3.Position = 1; + this.vboxContent.Add(this.hboxName); + Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.vboxContent[this.hboxName])); + w4.Position = 0; + w4.Expand = false; + w4.Fill = false; + w1.Add(this.vboxContent); + Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(w1[this.vboxContent])); + w5.Position = 0; + // Internal child MonoDevelop.Database.Designer.UserEditorDialog.ActionArea + Gtk.HButtonBox w6 = this.ActionArea; + w6.Name = "dialog1_ActionArea"; + w6.Spacing = 6; + w6.BorderWidth = ((uint)(5)); + w6.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonCancel = new Gtk.Button(); + this.buttonCancel.CanDefault = true; + this.buttonCancel.CanFocus = true; + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.UseStock = true; + this.buttonCancel.UseUnderline = true; + this.buttonCancel.Label = "gtk-cancel"; + this.AddActionWidget(this.buttonCancel, -6); + Gtk.ButtonBox.ButtonBoxChild w7 = ((Gtk.ButtonBox.ButtonBoxChild)(w6[this.buttonCancel])); + w7.Expand = false; + w7.Fill = false; + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonOk = new Gtk.Button(); + this.buttonOk.Sensitive = false; + this.buttonOk.CanDefault = true; + this.buttonOk.CanFocus = true; + this.buttonOk.Name = "buttonOk"; + this.buttonOk.UseStock = true; + this.buttonOk.UseUnderline = true; + this.buttonOk.Label = "gtk-ok"; + this.AddActionWidget(this.buttonOk, -5); + Gtk.ButtonBox.ButtonBoxChild w8 = ((Gtk.ButtonBox.ButtonBoxChild)(w6[this.buttonOk])); + w8.Position = 1; + w8.Expand = false; + w8.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.DefaultWidth = 640; + this.DefaultHeight = 480; + this.Show(); + this.entryName.Changed += new System.EventHandler(this.NameChanged); + this.buttonCancel.Clicked += new System.EventHandler(this.CancelClicked); + this.buttonOk.Clicked += new System.EventHandler(this.OkClicked); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.ViewEditorDialog.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.ViewEditorDialog.cs new file mode 100644 index 0000000000..1914c18b3e --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/MonoDevelop.Database.Designer.ViewEditorDialog.cs @@ -0,0 +1,149 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace MonoDevelop.Database.Designer { + + + public partial class ViewEditorDialog { + + private Gtk.VBox vboxContent; + + private Gtk.HBox hboxName; + + private Gtk.Label label7; + + private Gtk.Entry entryName; + + private Gtk.HBox hboxWarning; + + private Gtk.Image imageWarning; + + private Gtk.Label labelWarning; + + private Gtk.Button buttonCancel; + + private Gtk.Button buttonOk; + + protected virtual void Build() { + Stetic.Gui.Initialize(this); + // Widget MonoDevelop.Database.Designer.ViewEditorDialog + this.Name = "MonoDevelop.Database.Designer.ViewEditorDialog"; + this.WindowPosition = ((Gtk.WindowPosition)(4)); + this.HasSeparator = false; + // Internal child MonoDevelop.Database.Designer.ViewEditorDialog.VBox + Gtk.VBox w1 = this.VBox; + w1.Name = "dialog1_VBox"; + w1.BorderWidth = ((uint)(2)); + // Container child dialog1_VBox.Gtk.Box+BoxChild + this.vboxContent = new Gtk.VBox(); + this.vboxContent.Name = "vboxContent"; + this.vboxContent.Spacing = 6; + this.vboxContent.BorderWidth = ((uint)(6)); + // Container child vboxContent.Gtk.Box+BoxChild + this.hboxName = new Gtk.HBox(); + this.hboxName.Name = "hboxName"; + this.hboxName.Spacing = 6; + // Container child hboxName.Gtk.Box+BoxChild + this.label7 = new Gtk.Label(); + this.label7.Name = "label7"; + this.label7.Xalign = 0F; + this.label7.LabelProp = Mono.Unix.Catalog.GetString("Name"); + this.hboxName.Add(this.label7); + Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.hboxName[this.label7])); + w2.Position = 0; + w2.Expand = false; + w2.Fill = false; + // Container child hboxName.Gtk.Box+BoxChild + this.entryName = new Gtk.Entry(); + this.entryName.CanFocus = true; + this.entryName.Name = "entryName"; + this.entryName.IsEditable = true; + this.entryName.InvisibleChar = '●'; + this.hboxName.Add(this.entryName); + Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.hboxName[this.entryName])); + w3.Position = 1; + this.vboxContent.Add(this.hboxName); + Gtk.Box.BoxChild w4 = ((Gtk.Box.BoxChild)(this.vboxContent[this.hboxName])); + w4.Position = 0; + w4.Expand = false; + w4.Fill = false; + // Container child vboxContent.Gtk.Box+BoxChild + this.hboxWarning = new Gtk.HBox(); + this.hboxWarning.Name = "hboxWarning"; + this.hboxWarning.Spacing = 6; + // Container child hboxWarning.Gtk.Box+BoxChild + this.imageWarning = new Gtk.Image(); + this.imageWarning.Name = "imageWarning"; + this.imageWarning.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-dialog-warning", Gtk.IconSize.Menu, 16); + this.hboxWarning.Add(this.imageWarning); + Gtk.Box.BoxChild w5 = ((Gtk.Box.BoxChild)(this.hboxWarning[this.imageWarning])); + w5.Position = 0; + w5.Expand = false; + w5.Fill = false; + // Container child hboxWarning.Gtk.Box+BoxChild + this.labelWarning = new Gtk.Label(); + this.labelWarning.Name = "labelWarning"; + this.labelWarning.Xalign = 0F; + this.labelWarning.LabelProp = ""; + this.hboxWarning.Add(this.labelWarning); + Gtk.Box.BoxChild w6 = ((Gtk.Box.BoxChild)(this.hboxWarning[this.labelWarning])); + w6.Position = 1; + this.vboxContent.Add(this.hboxWarning); + Gtk.Box.BoxChild w7 = ((Gtk.Box.BoxChild)(this.vboxContent[this.hboxWarning])); + w7.Position = 2; + w7.Expand = false; + w7.Fill = false; + w1.Add(this.vboxContent); + Gtk.Box.BoxChild w8 = ((Gtk.Box.BoxChild)(w1[this.vboxContent])); + w8.Position = 0; + // Internal child MonoDevelop.Database.Designer.ViewEditorDialog.ActionArea + Gtk.HButtonBox w9 = this.ActionArea; + w9.Name = "dialog1_ActionArea"; + w9.Spacing = 6; + w9.BorderWidth = ((uint)(5)); + w9.LayoutStyle = ((Gtk.ButtonBoxStyle)(4)); + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonCancel = new Gtk.Button(); + this.buttonCancel.CanDefault = true; + this.buttonCancel.CanFocus = true; + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.UseStock = true; + this.buttonCancel.UseUnderline = true; + this.buttonCancel.Label = "gtk-cancel"; + this.AddActionWidget(this.buttonCancel, -6); + Gtk.ButtonBox.ButtonBoxChild w10 = ((Gtk.ButtonBox.ButtonBoxChild)(w9[this.buttonCancel])); + w10.Expand = false; + w10.Fill = false; + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.buttonOk = new Gtk.Button(); + this.buttonOk.Sensitive = false; + this.buttonOk.CanDefault = true; + this.buttonOk.CanFocus = true; + this.buttonOk.Name = "buttonOk"; + this.buttonOk.UseStock = true; + this.buttonOk.UseUnderline = true; + this.buttonOk.Label = "gtk-ok"; + this.AddActionWidget(this.buttonOk, -5); + Gtk.ButtonBox.ButtonBoxChild w11 = ((Gtk.ButtonBox.ButtonBoxChild)(w9[this.buttonOk])); + w11.Position = 1; + w11.Expand = false; + w11.Fill = false; + if ((this.Child != null)) { + this.Child.ShowAll(); + } + this.DefaultWidth = 640; + this.DefaultHeight = 480; + this.Show(); + this.entryName.Changed += new System.EventHandler(this.NameChanged); + this.buttonCancel.Clicked += new System.EventHandler(this.CancelClicked); + this.buttonOk.Clicked += new System.EventHandler(this.OkClicked); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/generated.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/generated.cs new file mode 100644 index 0000000000..ebb1662eb0 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/generated.cs @@ -0,0 +1,115 @@ +// ------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by a tool. +// Mono Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +// ------------------------------------------------------------------------------ + +namespace Stetic { + + + internal class Gui { + + private static bool initialized; + + internal static void Initialize(Gtk.Widget iconRenderer) { + if ((Stetic.Gui.initialized == false)) { + Stetic.Gui.initialized = true; + } + } + } + + internal class BinContainer { + + private Gtk.Widget child; + + private Gtk.UIManager uimanager; + + public static BinContainer Attach(Gtk.Bin bin) { + BinContainer bc = new BinContainer(); + bin.SizeRequested += new Gtk.SizeRequestedHandler(bc.OnSizeRequested); + bin.SizeAllocated += new Gtk.SizeAllocatedHandler(bc.OnSizeAllocated); + bin.Added += new Gtk.AddedHandler(bc.OnAdded); + return bc; + } + + private void OnSizeRequested(object sender, Gtk.SizeRequestedArgs args) { + if ((this.child != null)) { + args.Requisition = this.child.SizeRequest(); + } + } + + private void OnSizeAllocated(object sender, Gtk.SizeAllocatedArgs args) { + if ((this.child != null)) { + this.child.Allocation = args.Allocation; + } + } + + private void OnAdded(object sender, Gtk.AddedArgs args) { + this.child = args.Widget; + } + + public void SetUiManager(Gtk.UIManager uim) { + this.uimanager = uim; + this.child.Realized += new System.EventHandler(this.OnRealized); + } + + private void OnRealized(object sender, System.EventArgs args) { + if ((this.uimanager != null)) { + Gtk.Widget w; + w = this.child.Toplevel; + if (((w != null) && typeof(Gtk.Window).IsInstanceOfType(w))) { + ((Gtk.Window)(w)).AddAccelGroup(this.uimanager.AccelGroup); + this.uimanager = null; + } + } + } + } + + internal class IconLoader { + + public static Gdk.Pixbuf LoadIcon(Gtk.Widget widget, string name, Gtk.IconSize size, int sz) { + Gdk.Pixbuf res = widget.RenderIcon(name, size, null); + if ((res != null)) { + return res; + } + else { + try { + return Gtk.IconTheme.Default.LoadIcon(name, sz, 0); + } + catch (System.Exception ) { + if ((name != "gtk-missing-image")) { + return Stetic.IconLoader.LoadIcon(widget, "gtk-missing-image", size, sz); + } + else { + Gdk.Pixmap pmap = new Gdk.Pixmap(Gdk.Screen.Default.RootWindow, sz, sz); + Gdk.GC gc = new Gdk.GC(pmap); + gc.RgbFgColor = new Gdk.Color(255, 255, 255); + pmap.DrawRectangle(gc, true, 0, 0, sz, sz); + gc.RgbFgColor = new Gdk.Color(0, 0, 0); + pmap.DrawRectangle(gc, false, 0, 0, (sz - 1), (sz - 1)); + gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round); + gc.RgbFgColor = new Gdk.Color(255, 0, 0); + pmap.DrawLine(gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4))); + pmap.DrawLine(gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4))); + return Gdk.Pixbuf.FromDrawable(pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz); + } + } + } + } + } + + internal class ActionGroups { + + public static Gtk.ActionGroup GetActionGroup(System.Type type) { + return Stetic.ActionGroups.GetActionGroup(type.FullName); + } + + public static Gtk.ActionGroup GetActionGroup(string name) { + return null; + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/gui.stetic b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/gui.stetic new file mode 100644 index 0000000000..2ca7e4e11d --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/gui.stetic @@ -0,0 +1,1679 @@ +<?xml version="1.0" encoding="utf-8"?> +<stetic-interface> + <configuration> + <images-root-path>../</images-root-path> + <target-gtk-version>2.10.0</target-gtk-version> + </configuration> + <import> + <widget-library name="../../../../build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Components.dll" /> + <widget-library name="../../../../build/bin/MonoDevelop.Components.dll" /> + <widget-library name="../../../../build/bin/MonoDevelop.Ide.dll" /> + <widget-library name="../../../../build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Designer.dll" internal="true" /> + </import> + <widget class="Gtk.Bin" id="MonoDevelop.Database.Designer.TriggersEditorWidget" design-size="422 300"> + <property name="MemberName" /> + <child> + <widget class="Gtk.VPaned" id="vpaned"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Position">205</property> + <child> + <widget class="Gtk.HBox" id="hbox"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.ScrolledWindow" id="windowTriggers"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <child> + <widget class="Gtk.TreeView" id="listTriggers"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="HeadersClickable">True</property> + </widget> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + </packing> + </child> + <child> + <widget class="Gtk.VButtonBox" id="vbuttonbox"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="Size">2</property> + <property name="LayoutStyle">Start</property> + <child> + <widget class="Gtk.Button" id="buttonAdd"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-add</property> + <signal name="Clicked" handler="AddClicked" /> + <property name="label">gtk-add</property> + </widget> + <packing> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonRemove"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-remove</property> + <signal name="Clicked" handler="RemoveClicked" /> + <property name="label">gtk-remove</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Resize">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Frame" id="frame"> + <property name="MemberName" /> + <property name="ShadowType">None</property> + <property name="LabelXalign">0</property> + <child> + <widget class="Gtk.Alignment" id="alignment"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="Yalign">0</property> + <property name="LeftPadding">12</property> + <child> + <widget class="MonoDevelop.Database.Components.SqlEditorWidget" id="sqlEditor"> + <property name="MemberName" /> + <property name="HeightRequest">80</property> + <property name="Events">ButtonPressMask</property> + <property name="Editable">False</property> + </widget> + </child> + </widget> + </child> + <child> + <widget class="Gtk.Label" id="GtkLabel2"> + <property name="MemberName" /> + <property name="LabelProp" translatable="yes">Statement</property> + <property name="UseMarkup">True</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Bin" id="MonoDevelop.Database.Designer.ColumnsEditorWidget" design-size="668 400"> + <property name="MemberName" /> + <child> + <widget class="Gtk.HPaned" id="hpaned"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Position">662</property> + <child> + <widget class="Gtk.VBox" id="vboxLeft"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.ScrolledWindow" id="scrolledwindowLeft"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <child> + <widget class="Gtk.TreeView" id="treeColumns"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="HeadersClickable">True</property> + </widget> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + </packing> + </child> + <child> + <widget class="Gtk.HButtonBox" id="hbuttonbox"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="Size">4</property> + <property name="LayoutStyle">Start</property> + <child> + <widget class="Gtk.Button" id="buttonAdd"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-add</property> + <signal name="Clicked" handler="AddClicked" /> + <property name="label">gtk-add</property> + </widget> + <packing> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonRemove"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-remove</property> + <signal name="Clicked" handler="RemoveClicked" /> + <property name="label">gtk-remove</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonUp"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-go-up</property> + <signal name="Clicked" handler="UpClicked" /> + <property name="label">gtk-go-up</property> + </widget> + <packing> + <property name="Position">2</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonDown"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-go-down</property> + <signal name="Clicked" handler="DownClicked" /> + <property name="label">gtk-go-down</property> + </widget> + <packing> + <property name="Position">3</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Resize">False</property> + </packing> + </child> + <child> + <widget class="Gtk.ScrolledWindow" id="scrolledwindowRight"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <child> + <widget class="Gtk.Viewport" id="GtkViewport1"> + <property name="MemberName" /> + <property name="ShadowType">None</property> + <child> + <placeholder /> + </child> + </widget> + </child> + </widget> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Bin" id="MonoDevelop.Database.Designer.ConstraintsEditorWidget" design-size="615 342"> + <property name="MemberName" /> + <child> + <placeholder /> + </child> + </widget> + <widget class="Gtk.Bin" id="MonoDevelop.Database.Designer.IndicesEditorWidget" design-size="300 300"> + <property name="MemberName" /> + <child> + <placeholder /> + </child> + </widget> + <widget class="Gtk.Dialog" id="MonoDevelop.Database.Designer.TableEditorDialog" design-size="640 480"> + <property name="MemberName" /> + <property name="Title" translatable="yes">Edit Table</property> + <property name="TypeHint">Dialog</property> + <property name="WindowPosition">Center</property> + <property name="SkipTaskbarHint">True</property> + <property name="Buttons">2</property> + <property name="HelpButton">False</property> + <property name="HasSeparator">False</property> + <child internal-child="VBox"> + <widget class="Gtk.VBox" id="dialog1_VBox"> + <property name="MemberName" /> + <property name="BorderWidth">2</property> + <child> + <widget class="Gtk.VBox" id="vboxContent"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="BorderWidth">6</property> + <child> + <widget class="Gtk.HBox" id="hboxName"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.Label" id="label7"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Name</property> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Entry" id="entryName"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="IsEditable">True</property> + <property name="InvisibleChar">●</property> + <signal name="Changed" handler="NameChanged" /> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <placeholder /> + </child> + <child> + <widget class="Gtk.HBox" id="hboxWarning"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.Image" id="imageWarning"> + <property name="MemberName" /> + <property name="Pixbuf">stock:gtk-dialog-warning Menu</property> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="labelWarning"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes" /> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">False</property> + </packing> + </child> + </widget> + <packing> + <property name="PackType">End</property> + <property name="Position">2</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.CheckButton" id="checkPreview"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Label" translatable="yes">Preview SQL</property> + <property name="Active">True</property> + <property name="DrawIndicator">True</property> + <property name="HasLabel">True</property> + <property name="UseUnderline">True</property> + </widget> + <packing> + <property name="PackType">End</property> + <property name="Position">3</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + </packing> + </child> + </widget> + </child> + <child internal-child="ActionArea"> + <widget class="Gtk.HButtonBox" id="dialog1_ActionArea"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="BorderWidth">5</property> + <property name="Size">2</property> + <property name="LayoutStyle">End</property> + <child> + <widget class="Gtk.Button" id="buttonCancel"> + <property name="MemberName" /> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-cancel</property> + <property name="ResponseId">-6</property> + <signal name="Clicked" handler="CancelClicked" /> + <property name="label">gtk-cancel</property> + </widget> + <packing> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonOk"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-ok</property> + <property name="ResponseId">-5</property> + <signal name="Clicked" handler="OkClicked" /> + <property name="label">gtk-ok</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Dialog" id="MonoDevelop.Database.Designer.CreateDatabaseDialog" design-size="420 191"> + <property name="MemberName" /> + <property name="Title" translatable="yes">Create Database</property> + <property name="TypeHint">Dialog</property> + <property name="WindowPosition">Center</property> + <property name="SkipTaskbarHint">True</property> + <property name="Buttons">2</property> + <property name="HelpButton">False</property> + <property name="HasSeparator">False</property> + <child internal-child="VBox"> + <widget class="Gtk.VBox" id="dialog1_VBox"> + <property name="MemberName" /> + <property name="BorderWidth">2</property> + <child> + <widget class="Gtk.Table" id="table"> + <property name="MemberName" /> + <property name="NRows">3</property> + <property name="NColumns">3</property> + <property name="RowSpacing">6</property> + <property name="ColumnSpacing">6</property> + <property name="BorderWidth">6</property> + <child> + <widget class="Gtk.Button" id="buttonNew"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-new</property> + <signal name="Clicked" handler="NewClicked" /> + <property name="label">gtk-new</property> + </widget> + <packing> + <property name="LeftAttach">2</property> + <property name="RightAttach">3</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonSelect"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-save-as</property> + <signal name="Clicked" handler="SaveAsClicked" /> + <property name="label">gtk-save-as</property> + </widget> + <packing> + <property name="TopAttach">2</property> + <property name="BottomAttach">3</property> + <property name="LeftAttach">2</property> + <property name="RightAttach">3</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="MonoDevelop.Database.Components.DatabaseConnectionContextComboBox" id="comboConnections"> + <property name="MemberName" /> + <property name="IsTextCombo">False</property> + <property name="Items" translatable="yes" /> + <signal name="Changed" handler="ConnectionChanged" /> + </widget> + <packing> + <property name="LeftAttach">1</property> + <property name="RightAttach">2</property> + <property name="AutoSize">False</property> + <property name="YOptions">Fill</property> + <property name="XExpand">True</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Entry" id="entryDatabase"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="IsEditable">True</property> + <property name="InvisibleChar">●</property> + <signal name="Changed" handler="DatabaseNameChanged" /> + </widget> + <packing> + <property name="TopAttach">2</property> + <property name="BottomAttach">3</property> + <property name="LeftAttach">1</property> + <property name="RightAttach">2</property> + <property name="AutoSize">False</property> + <property name="YOptions">Fill</property> + <property name="XExpand">True</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Entry" id="entryName"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="IsEditable">True</property> + <property name="InvisibleChar">●</property> + <signal name="Changed" handler="NameChanged" /> + </widget> + <packing> + <property name="TopAttach">1</property> + <property name="BottomAttach">2</property> + <property name="LeftAttach">1</property> + <property name="RightAttach">3</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="label1"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Name</property> + </widget> + <packing> + <property name="TopAttach">1</property> + <property name="BottomAttach">2</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="label2"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Database</property> + </widget> + <packing> + <property name="TopAttach">2</property> + <property name="BottomAttach">3</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="label3"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Base Settings</property> + </widget> + <packing> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + </child> + <child internal-child="ActionArea"> + <widget class="Gtk.HButtonBox" id="dialog1_ActionArea"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="BorderWidth">5</property> + <property name="Size">2</property> + <property name="LayoutStyle">End</property> + <child> + <widget class="Gtk.Button" id="buttonCancel"> + <property name="MemberName" /> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-cancel</property> + <property name="ResponseId">-6</property> + <signal name="Clicked" handler="CancelClicked" /> + <property name="label">gtk-cancel</property> + </widget> + <packing> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonOk"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-ok</property> + <property name="ResponseId">-5</property> + <signal name="Clicked" handler="OkClicked" /> + <property name="label">gtk-ok</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Dialog" id="MonoDevelop.Database.Designer.ViewEditorDialog" design-size="640 480"> + <property name="MemberName" /> + <property name="WindowPosition">CenterOnParent</property> + <property name="Buttons">2</property> + <property name="HelpButton">False</property> + <property name="HasSeparator">False</property> + <child internal-child="VBox"> + <widget class="Gtk.VBox" id="dialog1_VBox"> + <property name="MemberName" /> + <property name="BorderWidth">2</property> + <child> + <widget class="Gtk.VBox" id="vboxContent"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="BorderWidth">6</property> + <child> + <widget class="Gtk.HBox" id="hboxName"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.Label" id="label7"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Name</property> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Entry" id="entryName"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="IsEditable">True</property> + <property name="InvisibleChar">●</property> + <signal name="Changed" handler="NameChanged" /> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <placeholder /> + </child> + <child> + <widget class="Gtk.HBox" id="hboxWarning"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.Image" id="imageWarning"> + <property name="MemberName" /> + <property name="Pixbuf">stock:gtk-dialog-warning Menu</property> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="labelWarning"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes" /> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">2</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + </packing> + </child> + </widget> + </child> + <child internal-child="ActionArea"> + <widget class="Gtk.HButtonBox" id="dialog1_ActionArea"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="BorderWidth">5</property> + <property name="Size">2</property> + <property name="LayoutStyle">End</property> + <child> + <widget class="Gtk.Button" id="buttonCancel"> + <property name="MemberName" /> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-cancel</property> + <property name="ResponseId">-6</property> + <signal name="Clicked" handler="CancelClicked" /> + <property name="label">gtk-cancel</property> + </widget> + <packing> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonOk"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-ok</property> + <property name="ResponseId">-5</property> + <signal name="Clicked" handler="OkClicked" /> + <property name="label">gtk-ok</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Dialog" id="MonoDevelop.Database.Designer.ProcedureEditorDialog" design-size="640 480"> + <property name="MemberName" /> + <property name="WindowPosition">CenterOnParent</property> + <property name="Buttons">2</property> + <property name="HelpButton">False</property> + <property name="HasSeparator">False</property> + <child internal-child="VBox"> + <widget class="Gtk.VBox" id="dialog1_VBox"> + <property name="MemberName" /> + <property name="BorderWidth">2</property> + <child> + <widget class="Gtk.VBox" id="vboxContent"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="BorderWidth">6</property> + <child> + <widget class="Gtk.HBox" id="hboxName"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.Label" id="label7"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Name</property> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Entry" id="entryName"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="IsEditable">True</property> + <property name="InvisibleChar">●</property> + <signal name="Changed" handler="NameChanged" /> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <placeholder /> + </child> + <child> + <widget class="Gtk.HBox" id="hboxWarning"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.Image" id="imageWarning"> + <property name="MemberName" /> + <property name="Pixbuf">stock:gtk-dialog-warning Menu</property> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="labelWarning"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes" /> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">2</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + </packing> + </child> + </widget> + </child> + <child internal-child="ActionArea"> + <widget class="Gtk.HButtonBox" id="dialog1_ActionArea"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="BorderWidth">5</property> + <property name="Size">2</property> + <property name="LayoutStyle">End</property> + <child> + <widget class="Gtk.Button" id="buttonCancel"> + <property name="MemberName" /> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-cancel</property> + <property name="ResponseId">-6</property> + <signal name="Clicked" handler="CancelClicked" /> + <property name="label">gtk-cancel</property> + </widget> + <packing> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonOk"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-ok</property> + <property name="ResponseId">-5</property> + <signal name="Clicked" handler="OkClicked" /> + <property name="label">gtk-ok</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Bin" id="MonoDevelop.Database.Designer.CommentEditorWidget" design-size="300 300"> + <property name="MemberName" /> + <child> + <widget class="Gtk.ScrolledWindow" id="scrolledwindow"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <child> + <widget class="Gtk.TextView" id="textComment"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Text" translatable="yes" /> + </widget> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Dialog" id="MonoDevelop.Database.Designer.PreviewDialog" design-size="528 382"> + <property name="MemberName" /> + <property name="Title" translatable="yes">Preview</property> + <property name="TypeHint">Dialog</property> + <property name="WindowPosition">Center</property> + <property name="SkipTaskbarHint">True</property> + <property name="Buttons">2</property> + <property name="HelpButton">False</property> + <property name="HasSeparator">False</property> + <child internal-child="VBox"> + <widget class="Gtk.VBox" id="dialog1_VBox"> + <property name="MemberName" /> + <property name="BorderWidth">2</property> + <child> + <widget class="Gtk.VBox" id="vboxContent"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="MonoDevelop.Database.Components.SqlEditorWidget" id="sqlEditor"> + <property name="MemberName" /> + <property name="Events">ButtonPressMask</property> + <property name="Editable">False</property> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + </packing> + </child> + </widget> + </child> + <child internal-child="ActionArea"> + <widget class="Gtk.HButtonBox" id="dialog1_ActionArea"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="BorderWidth">5</property> + <property name="Size">2</property> + <property name="LayoutStyle">End</property> + <child> + <widget class="Gtk.Button" id="buttonCancel"> + <property name="MemberName" /> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-cancel</property> + <property name="ResponseId">-6</property> + <signal name="Clicked" handler="CancelClicked" /> + <property name="label">gtk-cancel</property> + </widget> + <packing> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonOk"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-ok</property> + <property name="ResponseId">-5</property> + <signal name="Clicked" handler="OkClicked" /> + <property name="label">gtk-ok</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Dialog" id="MonoDevelop.Database.Designer.UserEditorDialog" design-size="640 480"> + <property name="MemberName" /> + <property name="WindowPosition">CenterOnParent</property> + <property name="Buttons">2</property> + <property name="HelpButton">False</property> + <property name="HasSeparator">False</property> + <child internal-child="VBox"> + <widget class="Gtk.VBox" id="dialog1_VBox"> + <property name="MemberName" /> + <property name="BorderWidth">2</property> + <child> + <widget class="Gtk.VBox" id="vboxContent"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="BorderWidth">6</property> + <child> + <widget class="Gtk.HBox" id="hboxName"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.Label" id="label7"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="LabelProp" translatable="yes">Name</property> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Entry" id="entryName"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="IsEditable">True</property> + <property name="InvisibleChar">●</property> + <signal name="Changed" handler="NameChanged" /> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <placeholder /> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + </packing> + </child> + </widget> + </child> + <child internal-child="ActionArea"> + <widget class="Gtk.HButtonBox" id="dialog1_ActionArea"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="BorderWidth">5</property> + <property name="Size">2</property> + <property name="LayoutStyle">End</property> + <child> + <widget class="Gtk.Button" id="buttonCancel"> + <property name="MemberName" /> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-cancel</property> + <property name="ResponseId">-6</property> + <signal name="Clicked" handler="CancelClicked" /> + <property name="label">gtk-cancel</property> + </widget> + <packing> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonOk"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanDefault">True</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-ok</property> + <property name="ResponseId">-5</property> + <signal name="Clicked" handler="OkClicked" /> + <property name="label">gtk-ok</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Bin" id="MonoDevelop.Database.Designer.ForeignKeyConstraintEditorWidget" design-size="443 300"> + <property name="MemberName" /> + <child> + <widget class="Gtk.HPaned" id="hpaned"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Position">293</property> + <child> + <widget class="Gtk.VBox" id="vbox3"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.ScrolledWindow" id="windowPK"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <child> + <widget class="Gtk.TreeView" id="listFK"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="HeadersClickable">True</property> + </widget> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + </packing> + </child> + <child> + <widget class="Gtk.HButtonBox" id="hbuttonbox"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="Size">2</property> + <property name="LayoutStyle">Start</property> + <child> + <widget class="Gtk.Button" id="buttonAdd"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-add</property> + <property name="label">gtk-add</property> + </widget> + <packing> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonRemove"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-remove</property> + <property name="label">gtk-remove</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Resize">False</property> + </packing> + </child> + <child> + <widget class="Gtk.VBox" id="vboxColumns"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.Frame" id="frame1"> + <property name="MemberName" /> + <property name="ShadowType">None</property> + <property name="LabelXalign">0</property> + <child> + <widget class="Gtk.Alignment" id="GtkAlignment2"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="Yalign">0</property> + <property name="LeftPadding">12</property> + <child> + <widget class="MonoDevelop.Database.Components.SelectColumnWidget" id="columnSelecter"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanFocus">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <property name="SingleCheck">False</property> + </widget> + </child> + </widget> + </child> + <child> + <widget class="Gtk.Label" id="GtkLabel2"> + <property name="MemberName" /> + <property name="LabelProp" translatable="yes">Columns</property> + <property name="UseMarkup">True</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Frame" id="frame2"> + <property name="MemberName" /> + <property name="ShadowType">None</property> + <property name="LabelXalign">0</property> + <child> + <widget class="Gtk.Alignment" id="GtkAlignment3"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="Yalign">0</property> + <property name="LeftPadding">12</property> + <child> + <widget class="MonoDevelop.Database.Components.SelectColumnWidget" id="referenceColumnSelecter"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanFocus">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <property name="SingleCheck">False</property> + </widget> + </child> + </widget> + </child> + <child> + <widget class="Gtk.Label" id="GtkLabel3"> + <property name="MemberName" /> + <property name="LabelProp" translatable="yes">Reference Columns</property> + <property name="UseMarkup">True</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Bin" id="MonoDevelop.Database.Designer.CheckConstraintEditorWidget" design-size="497 357"> + <property name="MemberName" /> + <child> + <widget class="Gtk.VPaned" id="vpaned"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Position">189</property> + <child> + <widget class="Gtk.HBox" id="hbox"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.ScrolledWindow" id="windowCheck"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <child> + <widget class="Gtk.TreeView" id="listCheck"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="HeadersClickable">True</property> + </widget> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + </packing> + </child> + <child> + <widget class="Gtk.VButtonBox" id="vbuttonbox"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="Size">2</property> + <property name="LayoutStyle">Start</property> + <child> + <widget class="Gtk.Button" id="buttonAdd"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-add</property> + <signal name="Clicked" handler="AddClicked" /> + <property name="label">gtk-add</property> + </widget> + <packing> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonRemove"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-remove</property> + <signal name="Clicked" handler="RemoveClicked" /> + <property name="label">gtk-remove</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Resize">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Frame" id="frame"> + <property name="MemberName" /> + <property name="ShadowType">None</property> + <property name="LabelXalign">0</property> + <child> + <widget class="Gtk.Alignment" id="alignment"> + <property name="MemberName" /> + <property name="Xalign">0</property> + <property name="Yalign">0</property> + <property name="LeftPadding">12</property> + <child> + <widget class="MonoDevelop.Database.Components.SqlEditorWidget" id="sqlEditor"> + <property name="MemberName" /> + <property name="Events">ButtonPressMask</property> + <property name="Editable">False</property> + </widget> + </child> + </widget> + </child> + <child> + <widget class="Gtk.Label" id="GtkLabel2"> + <property name="MemberName" /> + <property name="LabelProp" translatable="yes">Check Condition</property> + <property name="UseMarkup">True</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Bin" id="MonoDevelop.Database.Designer.PrimaryKeyConstraintEditorWidget" design-size="449 341"> + <property name="MemberName" /> + <child> + <widget class="Gtk.HPaned" id="hpaned"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Position">293</property> + <child> + <widget class="Gtk.VBox" id="vbox3"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.ScrolledWindow" id="windowPK"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <child> + <widget class="Gtk.TreeView" id="listPK"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="HeadersClickable">True</property> + </widget> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + </packing> + </child> + <child> + <widget class="Gtk.HButtonBox" id="hbuttonbox"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="Size">2</property> + <property name="LayoutStyle">Start</property> + <child> + <widget class="Gtk.Button" id="buttonAdd"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-add</property> + <signal name="Clicked" handler="AddClicked" /> + <property name="label">gtk-add</property> + </widget> + <packing> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonRemove"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-remove</property> + <signal name="Clicked" handler="RemoveClicked" /> + <property name="label">gtk-remove</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Resize">False</property> + </packing> + </child> + <child> + <widget class="MonoDevelop.Database.Components.SelectColumnWidget" id="columnSelecter"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanFocus">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <property name="SingleCheck">False</property> + </widget> + </child> + </widget> + </child> + </widget> + <widget class="Gtk.Bin" id="MonoDevelop.Database.Designer.UniqueConstraintEditorWidget" design-size="439 300"> + <property name="MemberName" /> + <child> + <widget class="Gtk.HPaned" id="hpaned"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Position">304</property> + <child> + <widget class="Gtk.VBox" id="vbox3"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.ScrolledWindow" id="windowPK"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <child> + <widget class="Gtk.TreeView" id="listUnique"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="HeadersClickable">True</property> + </widget> + </child> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">True</property> + </packing> + </child> + <child> + <widget class="Gtk.HButtonBox" id="hbuttonbox"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <property name="Size">2</property> + <property name="LayoutStyle">Start</property> + <child> + <widget class="Gtk.Button" id="buttonAdd"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-add</property> + <signal name="Clicked" handler="AddClicked" /> + <property name="label">gtk-add</property> + </widget> + <packing> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Button" id="buttonRemove"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanFocus">True</property> + <property name="UseStock">True</property> + <property name="Type">StockItem</property> + <property name="StockId">gtk-remove</property> + <signal name="Clicked" handler="RemoveClicked" /> + <property name="label">gtk-remove</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Resize">False</property> + </packing> + </child> + <child> + <widget class="MonoDevelop.Database.Components.SelectColumnWidget" id="columnSelecter"> + <property name="MemberName" /> + <property name="Sensitive">False</property> + <property name="CanFocus">True</property> + <property name="VscrollbarPolicy">Automatic</property> + <property name="HscrollbarPolicy">Automatic</property> + <property name="ShadowType">In</property> + <property name="SingleCheck">False</property> + </widget> + </child> + </widget> + </child> + </widget> +</stetic-interface>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/objects.xml b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/objects.xml new file mode 100644 index 0000000000..5b7554f002 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Designer/gtk-gui/objects.xml @@ -0,0 +1,75 @@ +<objects> + <object type="MonoDevelop.Database.Designer.ColumnsEditorWidget" palette-category="widget" allow-children="false" base-type="Gtk.Bin"> + <itemgroups /> + <signals> + <itemgroup label="ColumnsEditorWidget Signals"> + <signal name="ContentChanged" /> + </itemgroup> + </signals> + </object> + <object type="MonoDevelop.Database.Designer.TriggersEditorWidget" palette-category="widget" allow-children="false" base-type="Gtk.Bin"> + <itemgroups /> + <signals> + <itemgroup label="TriggersEditorWidget Signals"> + <signal name="ContentChanged" /> + </itemgroup> + </signals> + </object> + <object type="MonoDevelop.Database.Designer.ConstraintsEditorWidget" palette-category="widget" allow-children="false" base-type="Gtk.Bin"> + <itemgroups /> + <signals> + <itemgroup label="ConstraintsEditorWidget Signals"> + <signal name="ContentChanged" /> + </itemgroup> + </signals> + </object> + <object type="MonoDevelop.Database.Designer.IndicesEditorWidget" palette-category="widget" allow-children="false" base-type="Gtk.Bin"> + <itemgroups /> + <signals> + <itemgroup label="IndicesEditorWidget Signals"> + <signal name="ContentChanged" /> + </itemgroup> + </signals> + </object> + <object type="MonoDevelop.Database.Designer.CommentEditorWidget" palette-category="widget" allow-children="false" base-type="Gtk.Bin"> + <itemgroups> + <itemgroup label="CommentEditorWidget Properties"> + <property name="Comment" /> + </itemgroup> + </itemgroups> + <signals> + </signals> + </object> + <object type="MonoDevelop.Database.Designer.ForeignKeyConstraintEditorWidget" palette-category="widget" allow-children="false" base-type="Gtk.Bin"> + <itemgroups /> + <signals> + <itemgroup label="ForeignKeyConstraintEditorWidget Signals"> + <signal name="ContentChanged" /> + </itemgroup> + </signals> + </object> + <object type="MonoDevelop.Database.Designer.CheckConstraintEditorWidget" palette-category="widget" allow-children="false" base-type="Gtk.Bin"> + <itemgroups /> + <signals> + <itemgroup label="CheckConstraintEditorWidget Signals"> + <signal name="ContentChanged" /> + </itemgroup> + </signals> + </object> + <object type="MonoDevelop.Database.Designer.PrimaryKeyConstraintEditorWidget" palette-category="widget" allow-children="false" base-type="Gtk.Bin"> + <itemgroups /> + <signals> + <itemgroup label="PrimaryKeyConstraintEditorWidget Signals"> + <signal name="ContentChanged" /> + </itemgroup> + </signals> + </object> + <object type="MonoDevelop.Database.Designer.UniqueConstraintEditorWidget" palette-category="widget" allow-children="false" base-type="Gtk.Bin"> + <itemgroups /> + <signals> + <itemgroup label="UniqueConstraintEditorWidget Signals"> + <signal name="ContentChanged" /> + </itemgroup> + </signals> + </object> +</objects>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/AssemblyInfo.cs.in b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/AssemblyInfo.cs.in new file mode 100644 index 0000000000..a1762077fc --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/AssemblyInfo.cs.in @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("MonoDevelop.Database.Query")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("http://www.monodevelop.com")] +[assembly: AssemblyCopyright("MIT X11 - Ben Motmans")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: AssemblyVersion("@ASSEMBLY_VERSION@")] + +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/ChangeLog b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/ChangeLog new file mode 100644 index 0000000000..569253b401 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/ChangeLog @@ -0,0 +1,87 @@ +2007-10-29 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Query.addin.xml: Bump MD version. + +2007-10-25 Lluis Sanchez Gual <lluis@novell.com> + + * QueryResultView.cs, SqlQueryView.cs: Destroy the view widget when the view + is disposed. + +2007-10-23 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Query.mdp: Project file names updated by change in MD + path functions. + +2007-10-16 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Query.mdp: Fix required GTK# version. + +2007-09-26 Michael Hutchinson <mhutchinson@novell.com> + + * Makefile.am: Don't deploy .addin.xml file. + * MonoDevelop.Database.Query.mdp: Don't unnecessarily local-copy project + references. Don't sync EXTRA_DIST with deploy files. Add Makefile.am to + file list. + +2007-09-21 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Query.addin.xml: Bump MD version. + +2007-09-19 Ben Motmans <ben.motmans@gmail.com> + + * SqlQueryView.cs: small bugfixes + +2007-09-16 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: link to the correct Mono.Addins dll + +2007-08-29 Ben Motmans <ben.motmans@gmail.com> + + * MonoDevelop.Database.Query.addin.xml: use updated ExtensionNodeSet + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am, MonoDevelop.Database.Query.mdp: use project references + instead of assembly references + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: updated makefile + * MonoDevelop.Database.Query.addin.xml: updated addin paths + +2007-08-03 Ben Motmans <ben.motmans@gmail.com> + + * SqlQueryView.cs: make use of the DatabaseConnectionContextComboBox in the toolbar + instead of a menu toolitem + +2007-08-01 Ben Motmans <ben.motmans@gmail.com> + + * SqlQueryView.cs: Use correct strings when showing results and don't allow + the execute button to be clicked when no statement is entered + +2007-07-25 Ben Motmans <ben.motmans@gmail.com> + + * SqlQueryView.cs: Show query results in the same view using a VPaned + +2007-07-15 Ben Motmans <ben.motmans@gmail.com> + + * Commands/ToolCommands.cs, MonoDevelop.Database.Query.addin.xml: moved generator commands + to GlueGenerator project + +2007-07-14 Ben Motmans <ben.motmans@gmail.com> + + * SqlQueryView.cs: use MenuToolButton to display a list of stored connections + + improved handling of query cancelling + * QueryService.cs: small changes due to Mono.Data.Sql API updates + +2007-07-10 Ben Motmans <ben.motmans@gmail.com> + + * DataGrid/*: moved DataGrid control to Components project + * QueryService.cs: helper service for easy database access + * SqlQueryView.cs: View to execute SQL queries + +2007-07-05 Ben Motmans <ben.motmans@gmail.com> + + * DataGrid/*: new DataGrid implementation based on Gtk.TreeView, support for record navigation, + data visualizers and different column types + * QueryResultView.cs: View to visualize the result of a query, based on the new DataGrid diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/Commands/ToolCommands.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/Commands/ToolCommands.cs new file mode 100644 index 0000000000..aacabe809c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/Commands/ToolCommands.cs @@ -0,0 +1,51 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using Gtk; +using System; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui; +using MonoDevelop.Ide.Gui.Pads; +using MonoDevelop.Components.Commands; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Query +{ + public enum ToolCommands + { + Query + } + + public class QueryHandler : CommandHandler + { + protected override void Run () + { + SqlQueryView view = new SqlQueryView (); + IdeApp.Workbench.OpenDocument (view, true); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/Makefile.am b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/Makefile.am new file mode 100644 index 0000000000..620a9e7c9a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/Makefile.am @@ -0,0 +1,71 @@ +ADDIN_BUILD = $(top_builddir)/build/AddIns/MonoDevelop.Database +ASSEMBLY = $(ADDIN_BUILD)/MonoDevelop.Database.Query.dll +REFS = \ + $(GLADE_SHARP_LIBS) \ + $(GLIB_SHARP_LIBS) \ + $(GTK_SHARP_LIBS) \ + $(GTKSOURCEVIEW_SHARP_LIBS) \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Components.dll \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Sql.dll \ + -r:$(top_builddir)/build/bin/Mono.Addins.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Components.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.Gui.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Ide.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Projects.dll \ + -r:Mono.Posix \ + -r:System \ + -r:System.Data + +RES = \ + icons/Icons.16x16.Database.Column.Key.png \ + icons/Icons.16x16.Database.Column.png \ + icons/Icons.16x16.Database.Connection.Error.png \ + icons/Icons.16x16.Database.Connection.png \ + icons/Icons.16x16.Database.Connection.Remove.png \ + icons/Icons.16x16.Database.Constraints.png \ + icons/Icons.16x16.Database.Database.Error.png \ + icons/Icons.16x16.Database.Database.Ok.png \ + icons/Icons.16x16.Database.Database.png \ + icons/Icons.16x16.Database.Execute.png \ + icons/Icons.16x16.Database.Parameter.png \ + icons/Icons.16x16.Database.Procedure.Error.png \ + icons/Icons.16x16.Database.Procedure.png \ + icons/Icons.16x16.Database.Procedure.Source.png \ + icons/Icons.16x16.Database.Relations.png \ + icons/Icons.16x16.Database.Table.Error.png \ + icons/Icons.16x16.Database.Table.png \ + icons/Icons.16x16.Database.Tables.png \ + icons/Icons.16x16.Database.User.png \ + icons/Icons.16x16.Database.Users.png \ + icons/Icons.16x16.Database.View.Error.png \ + icons/Icons.16x16.Database.View.png \ + icons/Icons.16x16.Database.View.Source.png \ + icons/Icons.16x16.Database.Views.png \ + MonoDevelop.Database.Query.addin.xml + +FILES = \ + Commands/ToolCommands.cs \ + QueryResultView.cs \ + SqlQueryView.cs + +if ENABLE_DATABASE +all: $(ASSEMBLY) +else
+all:
+endif + +$(ASSEMBLY): $(FILES) $(build_resources) + mkdir -p $(ADDIN_BUILD) + $(CSC) $(CSC_FLAGS) $(REFS) $(build_resources:%=/resource:%) $(build_sources) -out:$@ -target:library + + +if ENABLE_DATABASE +assemblydir = $(MD_ADDIN_DIR)/MonoDevelop.Database +assembly_DATA = $(ASSEMBLY) +endif + +CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb +EXTRA_DIST = $(FILES) $(RES) + +include $(top_srcdir)/Makefile.include diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/MonoDevelop.Database.Query.addin.xml b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/MonoDevelop.Database.Query.addin.xml new file mode 100644 index 0000000000..36730013d9 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/MonoDevelop.Database.Query.addin.xml @@ -0,0 +1,66 @@ +<Addin id = "Database.Query" + namespace = "MonoDevelop" + name = "MonoDevelop Database Query" + author = "Christian Hergert, Daniel Morgan, Ben Motmans" + copyright = "MIT X11" + url = "http://www.monodevelop.com" + description = "Database Query Module" + version = "0.17.0"> + + <Runtime> + <Import assembly="MonoDevelop.Database.Query.dll"/> + </Runtime> + + <Dependencies> + <Addin id="Core" version="0.17.0"/> + <Addin id="Core.Gui" version="0.17.0"/> + <Addin id="Ide" version="0.17.0"/> + <Addin id="Database.Sql" version="0.17.0"/> + <Addin id="Database.Components" version="0.17.0"/> + </Dependencies> + + <ExtensionPoint path = "/MonoDevelop/Database/ToolBar/SqlQueryView"> + <ExtensionNodeSet id="MonoDevelop.Components.Commands.ItemSet"/> + </ExtensionPoint> + + <Extension path = "/MonoDevelop/Ide/Commands"> + <Command id = "MonoDevelop.Database.Query.ToolCommands.Query" + defaultHandler = "MonoDevelop.Database.Query.QueryHandler" + _label = "Query Database" + icon = "md-db-execute"/> + </Extension> + + <Extension path = "/MonoDevelop/Ide/MainMenu/Tools"> + <SeparatorItem id = "DatabaseSeparator" insertafter = "MonoDevelop.Ide.Commands.ToolCommands.AddinManager" /> + <ItemSet id = "Database" _label = "_Database"> + <CommandItem id = "MonoDevelop.Database.Query.ToolCommands.Query" /> + </ItemSet> + </Extension> + + <Extension path = "/MonoDevelop/Core/StockIcons"> + <StockIcon stockid = "md-db-column-key" resource = "Icons.16x16.Database.Column.Key.png" /> + <StockIcon stockid = "md-db-column" resource = "Icons.16x16.Database.Column.png" /> + <StockIcon stockid = "md-db-connection-error" resource = "Icons.16x16.Database.Connection.Error.png" /> + <StockIcon stockid = "md-db-connection" resource = "Icons.16x16.Database.Connection.png" /> + <StockIcon stockid = "md-db-constraints" resource = "Icons.16x16.Database.Constraints.png" /> + <StockIcon stockid = "md-db-database-error" resource = "Icons.16x16.Database.Database.Error.png" /> + <StockIcon stockid = "md-db-database-ok" resource = "Icons.16x16.Database.Database.Ok.png" /> + <StockIcon stockid = "md-db-database" resource = "Icons.16x16.Database.Database.png" /> + <StockIcon stockid = "md-db-execute" resource = "Icons.16x16.Database.Execute.png" /> + <StockIcon stockid = "md-db-parameter" resource = "Icons.16x16.Database.Parameter.png" /> + <StockIcon stockid = "md-db-procedure-error" resource = "Icons.16x16.Database.Procedure.Error.png" /> + <StockIcon stockid = "md-db-procedure" resource = "Icons.16x16.Database.Procedure.png" /> + <StockIcon stockid = "md-db-procedure-source" resource = "Icons.16x16.Database.Procedure.Source.png" /> + <StockIcon stockid = "md-db-relations" resource = "Icons.16x16.Database.Relations.png" /> + <StockIcon stockid = "md-db-table-error" resource = "Icons.16x16.Database.Table.Error.png" /> + <StockIcon stockid = "md-db-table" resource = "Icons.16x16.Database.Table.png" /> + <StockIcon stockid = "md-db-tables" resource = "Icons.16x16.Database.Tables.png" /> + <StockIcon stockid = "md-db-user" resource = "Icons.16x16.Database.User.png" /> + <StockIcon stockid = "md-db-users" resource = "Icons.16x16.Database.Users.png" /> + <StockIcon stockid = "md-db-view-error" resource = "Icons.16x16.Database.View.Error.png" /> + <StockIcon stockid = "md-db-view" resource = "Icons.16x16.Database.View.png" /> + <StockIcon stockid = "md-db-view-source" resource = "Icons.16x16.Database.View.Source.png" /> + <StockIcon stockid = "md-db-views" resource = "Icons.16x16.Database.Views.png" /> + </Extension> + +</Addin> diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/MonoDevelop.Database.Query.mdp b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/MonoDevelop.Database.Query.mdp new file mode 100644 index 0000000000..34b4b0b955 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/MonoDevelop.Database.Query.mdp @@ -0,0 +1,76 @@ +<Project name="MonoDevelop.Database.Query" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Query" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Query" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="True" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="MonoDevelop.Database.Query.addin.xml" subtype="Code" buildaction="EmbedAsResource" /> + <File name="QueryResultView.cs" subtype="Code" buildaction="Compile" /> + <File name="SqlQueryView.cs" subtype="Code" buildaction="Compile" /> + <File name="icons/Icons.16x16.Database.Column.Key.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Column.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Connection.Error.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Connection.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Connection.Remove.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Constraints.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Database.Error.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Database.Ok.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Database.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Execute.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Parameter.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Procedure.Error.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Procedure.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Procedure.Source.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Relations.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Table.Error.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Table.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Tables.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.User.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Users.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.View.Error.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.View.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.View.Source.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="icons/Icons.16x16.Database.Views.png" subtype="Code" buildaction="EmbedAsResource" /> + <File name="Commands/ToolCommands.cs" subtype="Code" buildaction="Compile" /> + <File name="Makefile.am" subtype="Code" buildaction="Nothing" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" /> + <ProjectReference type="Gac" localcopy="True" refto="gtksourceview-sharp, Version=1.0.0.2, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Sql" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Components" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core.Gui" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Components" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Ide" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Projects" /> + <ProjectReference type="Project" localcopy="False" refto="Mono.Addins" /> + <ProjectReference type="Gac" localcopy="True" refto="glade-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="glib-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="pango-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="atk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + </References> + <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am" BuildTargetName="" CleanTargetName="" SyncReferences="True" IsAutotoolsProject="True" RelativeConfigureInPath="../../../"> + <BuildFilesVar Sync="True" Name="FILES" /> + <DeployFilesVar /> + <ResourcesVar Sync="True" Name="RES" /> + <OthersVar /> + <GacRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <AsmRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <ProjectRefVar Sync="True" Name="REFS" Prefix="-r:" /> + </MonoDevelop.Autotools.MakefileInfo> +</Project>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/QueryResultView.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/QueryResultView.cs new file mode 100644 index 0000000000..17d505414f --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/QueryResultView.cs @@ -0,0 +1,82 @@ +// +// Authors: +// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Christian Hergert
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Data; +using System.Collections.Generic; +using Mono.Addins; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Ide.Gui; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.Query +{ + public class QueryResultView : AbstractViewContent + { + protected DataGrid grid; + + public QueryResultView () + : base () + { + grid = new DataGrid (); + grid.ShowAll (); + } + + public QueryResultView (DataTable table) + : this () + { + LoadDataTable (table); + } + + public override string UntitledName { + get { return "UntitledResult"; } + } + + public override void Dispose () + { + Control.Destroy (); + } + + public override void Load (string filename) + { + throw new NotImplementedException (); + } + + public void LoadDataTable (DataTable table) + { + grid.Clear (); + grid.DataSource = table; + grid.DataBind (); + } + + public override Widget Control { + get { return grid; } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/SqlQueryView.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/SqlQueryView.cs new file mode 100644 index 0000000000..4aa820dedd --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/SqlQueryView.cs @@ -0,0 +1,300 @@ +// +// Authors: +// Christian Hergert <chris@mosaix.net> +// Daniel Morgan <danielmorgan@verizon.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Christian Hergert +// Copyright (C) 2005 Daniel Morgan +// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using Gtk; +using System; +using System.Data; +using System.Threading; +using System.Collections.Generic; +using Mono.Addins; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Components; +using MonoDevelop.Ide.Gui; +using MonoDevelop.Database.Components; + +namespace MonoDevelop.Database.Query +{ + public class SqlQueryView : AbstractViewContent + { + private VBox vbox; + private SqlEditorWidget sqlEditor; + private ToolButton buttonExecute; + private ToolButton buttonStop; + private ToolButton buttonClear; + private DatabaseConnectionContextComboBox comboConnections; + private Notebook notebook; + private VPaned pane; + private TextView status; + + private object currentQueryState; + private List<object> stoppedQueries; + + private DatabaseConnectionContext selectedConnection; + + public SqlQueryView () + { + stoppedQueries = new List<object> (); + + vbox = new VBox (false, 6); + vbox.BorderWidth = 6; + + sqlEditor = new SqlEditorWidget (); + sqlEditor.TextChanged += new EventHandler (SqlChanged); + + Toolbar toolbar = new Toolbar (); + toolbar.ToolbarStyle = ToolbarStyle.BothHoriz; + + buttonExecute = new ToolButton ( + Services.Resources.GetImage ("md-db-execute", IconSize.SmallToolbar), + GettextCatalog.GetString ("Execute") + ); + buttonStop = new ToolButton ("gtk-stop"); + buttonClear = new ToolButton (Services.Resources.GetImage ("gtk-clear", IconSize.Button), GettextCatalog.GetString ("Clear Results")); + buttonStop.Sensitive = false; + buttonExecute.Sensitive = false; + + buttonExecute.Clicked += new EventHandler (ExecuteClicked); + buttonStop.Clicked += new EventHandler (StopClicked); + buttonClear.Clicked += new EventHandler (ClearClicked); + + comboConnections = new DatabaseConnectionContextComboBox (); + selectedConnection = comboConnections.DatabaseConnection; + comboConnections.Changed += new EventHandler (ConnectionChanged); + + buttonExecute.IsImportant = true; + + ToolItem comboItem = new ToolItem (); + comboItem.Child = comboConnections; + + toolbar.Add (buttonExecute); + toolbar.Add (buttonStop); + toolbar.Add (buttonClear); + toolbar.Add (new SeparatorToolItem ()); + toolbar.Add (comboItem); + + pane = new VPaned (); + + ScrolledWindow windowStatus = new ScrolledWindow (); + status = new TextView (); + windowStatus.Add (status); + + notebook = new Notebook (); + notebook.AppendPage (windowStatus, new Label (GettextCatalog.GetString ("Status"))); + + pane.Pack1 (sqlEditor, true, true); + pane.Pack2 (notebook, true, true); + + vbox.PackStart (toolbar, false, true, 0); + vbox.PackStart (pane, true, true, 0); + + vbox.ShowAll (); + notebook.Hide (); + } + + public string Text { + get { return sqlEditor.Text; } + set { sqlEditor.Text = value; } + } + + public DatabaseConnectionContext SelectedConnectionContext { + get { return selectedConnection; } + set { + if (selectedConnection != value) { + selectedConnection = value; + buttonExecute.Sensitive = value != null; + comboConnections.DatabaseConnection = value; + } + } + } + + public override string UntitledName { + get { return "SQL Query"; } + } + + public override void Dispose () + { + Control.Destroy (); + } + + public override void Load (string filename) + { + throw new NotImplementedException (); + } + + public override Widget Control { + get { return vbox; } + } + + public void ExecuteQuery () + { + if (selectedConnection == null || Text.Length < 0) { + SetQueryState (false, "No connection selected."); + return; + } + + QueryService.EnsureConnection (selectedConnection, new DatabaseConnectionContextCallback (ExecuteQueryCallback), null); + } + + private void ExecuteQueryCallback (DatabaseConnectionContext context, bool connected, object state) + { + if (!connected) { + Services.MessageService.ShowErrorFormatted ( + GettextCatalog.GetString ("Unable to connect to database '{0}'"), context.ConnectionSettings.Name); + return; + } + + currentQueryState = new object (); + IPooledDbConnection conn = context.ConnectionPool.Request (); + IDbCommand command = conn.CreateCommand (Text); + conn.ExecuteSetAsync (command, new ExecuteCallback<DataSet> (ExecuteQueryThreaded), currentQueryState); + } + + private void ExecuteQueryThreaded (IPooledDbConnection connection, DataSet result, object state) + { + connection.Release (); + + DispatchService.GuiDispatch (delegate () { + notebook.ShowAll (); + string msg = GettextCatalog.GetPluralString ("Query executed ({0} result table)", + "Query executed ({0} result tables)", result.Tables.Count); + SetQueryState (false, String.Format (msg, result.Tables.Count)); + }); + + if (stoppedQueries.Contains (state)) { + stoppedQueries.Remove (state); + return; + } + + if (result != null) { + foreach (DataTable table in result.Tables) { + DispatchService.GuiDispatch (delegate () { + MonoDevelop.Database.Components.DataGrid grid = new MonoDevelop.Database.Components.DataGrid (); + grid.DataSource = table; + grid.DataBind (); + + string msg = String.Concat (Environment.NewLine, GettextCatalog.GetString ("Table"), ": ",table.TableName, + Environment.NewLine, "\t", GettextCatalog.GetString ("Affected Rows"), ": ", table.Rows.Count); + status.Buffer.Text += msg; + + TabLabel label = new TabLabel (new Label (table.TableName), Services.Resources.GetImage ("md-db-table", IconSize.Menu)); + label.CloseClicked += new EventHandler (OnResultTabClose); + notebook.AppendPage (grid, label); + notebook.ShowAll (); + }); + } + } + + if (result == null || result.Tables.Count == 0) { + DispatchService.GuiDispatch (delegate () { + status.Buffer.Text += GettextCatalog.GetString ("No Results"); + }); + } + } + + private void OnResultTabClose (object sender, EventArgs args) + { + Widget tabLabel = (Widget)sender; + foreach (Widget child in notebook.Children) { + if (notebook.GetTabLabel (child) == tabLabel) { + notebook.Remove (child); + break; + } + } + } + + private void ExecuteClicked (object sender, EventArgs e) + { + SetQueryState (true, GettextCatalog.GetString ("Executing query")); + ExecuteQuery (); + } + + private void ClearClicked (object sender, EventArgs e) + { + for (int i=1; i<notebook.NPages; i++) + notebook.RemovePage (i); + status.Buffer.Text = String.Empty; + notebook.Hide (); + } + + private void StopClicked (object sender, EventArgs e) + { + SetQueryState (false, GettextCatalog.GetString ("Query execute cancelled")); + + //since we can't abort a threadpool task, each task is assigned a unique state + //when stop is pressed, the state is added to the list of results that need + //to be discarded when they get in + if (!stoppedQueries.Contains (currentQueryState)) + stoppedQueries.Add (currentQueryState); + } + + private void ConnectionChanged (object sender, EventArgs args) + { + selectedConnection = comboConnections.DatabaseConnection; + buttonExecute.Sensitive = sqlEditor.Text.Length > 0; + } + + private void SqlChanged (object sender, EventArgs args) + { + buttonExecute.Sensitive = sqlEditor.Text.Length > 0; + } + + private void SetQueryState (bool exec, string msg) + { + buttonExecute.Sensitive = !exec && sqlEditor.Text.Length > 0; + buttonStop.Sensitive = exec; + buttonClear.Sensitive = !exec; + sqlEditor.Editable = !exec; + notebook.Show (); + + status.Buffer.Text = msg + Environment.NewLine; + } + } + + internal class ConnectionContextMenuItem : RadioMenuItem + { + private DatabaseConnectionContext context; + + public ConnectionContextMenuItem (DatabaseConnectionContext context) + : base (context.ConnectionSettings.Name) + { + this.context = context; + } + + public DatabaseConnectionContext ConnectionContext { + get { return context; } + } + + public void Update () + { + (Child as Label).Text = context.ConnectionSettings.Name; + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Column.Key.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Column.Key.png Binary files differnew file mode 100644 index 0000000000..a9d5e4f8cc --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Column.Key.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Column.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Column.png Binary files differnew file mode 100644 index 0000000000..d37e7304e2 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Column.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Connection.Error.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Connection.Error.png Binary files differnew file mode 100644 index 0000000000..f640256399 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Connection.Error.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Connection.Remove.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Connection.Remove.png Binary files differnew file mode 100644 index 0000000000..61e740fe18 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Connection.Remove.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Connection.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Connection.png Binary files differnew file mode 100644 index 0000000000..720a237c73 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Connection.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Constraints.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Constraints.png Binary files differnew file mode 100644 index 0000000000..4ec1a92814 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Constraints.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Database.Error.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Database.Error.png Binary files differnew file mode 100644 index 0000000000..578221aaab --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Database.Error.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Database.Ok.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Database.Ok.png Binary files differnew file mode 100644 index 0000000000..61a8556c40 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Database.Ok.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Database.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Database.png Binary files differnew file mode 100644 index 0000000000..3d09261a26 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Database.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Execute.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Execute.png Binary files differnew file mode 100644 index 0000000000..9680afd12f --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Execute.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Parameter.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Parameter.png Binary files differnew file mode 100644 index 0000000000..e093032a77 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Parameter.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Procedure.Error.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Procedure.Error.png Binary files differnew file mode 100644 index 0000000000..04919548e6 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Procedure.Error.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Procedure.Source.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Procedure.Source.png Binary files differnew file mode 100644 index 0000000000..63fe6ceff5 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Procedure.Source.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Procedure.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Procedure.png Binary files differnew file mode 100644 index 0000000000..0f9ed4d483 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Procedure.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Relations.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Relations.png Binary files differnew file mode 100644 index 0000000000..28b8505c0e --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Relations.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Table.Error.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Table.Error.png Binary files differnew file mode 100644 index 0000000000..589e92b554 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Table.Error.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Table.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Table.png Binary files differnew file mode 100644 index 0000000000..abcd93689a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Table.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Tables.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Tables.png Binary files differnew file mode 100644 index 0000000000..d76448e34a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Tables.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.User.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.User.png Binary files differnew file mode 100644 index 0000000000..79f35ccbda --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.User.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Users.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Users.png Binary files differnew file mode 100644 index 0000000000..7fb4e1f1e1 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Users.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.View.Error.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.View.Error.png Binary files differnew file mode 100644 index 0000000000..f07f449a44 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.View.Error.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.View.Source.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.View.Source.png Binary files differnew file mode 100644 index 0000000000..f7ea90419d --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.View.Source.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.View.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.View.png Binary files differnew file mode 100644 index 0000000000..03ddd799fa --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.View.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Views.png b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Views.png Binary files differnew file mode 100644 index 0000000000..195dc6d6c3 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.16x16.Database.Views.png diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.License.txt b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.License.txt new file mode 100644 index 0000000000..5e380afe13 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Query/icons/Icons.License.txt @@ -0,0 +1,10 @@ +Website: http://www.famfamfam.com/lab/icons/silk/ +License: Creative Commons Attribution 2.5 License (http://creativecommons.org/licenses/by/2.5/) + +Note: +I also love to hear of my work being used, feel encouraged to send an email with a link or +screenshot of the icons in their new home to mjames at gmail dot com. This work is licensed +under a Creative Commons Attribution 2.5 License. This means you may use it for any purpose, +and make any changes you like. All I ask is that you include a link back to this page in your +credits (although a giant link on every page of your website really isn't needed, contact me +to discuss specifics). diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/AssemblyInfo.cs.in b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/AssemblyInfo.cs.in new file mode 100644 index 0000000000..7fb3ddc78c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/AssemblyInfo.cs.in @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("Mono.Data.Sql.Firebird")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("http://www.monodevelop.com")] +[assembly: AssemblyCopyright("MIT X11 - Christian Hergert, Daniel Morgan, Ben Motmans")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: AssemblyVersion("@ASSEMBLY_VERSION@")] + +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")]
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/ChangeLog b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/ChangeLog new file mode 100644 index 0000000000..4778b38b6a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/ChangeLog @@ -0,0 +1,42 @@ +2007-10-29 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Firebird.addin.xml: Bump MD version. + +2007-10-23 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Firebird.mdp: Project file names updated by + change in MD path functions. + +2007-09-26 Michael Hutchinson <mhutchinson@novell.com> + + * MonoDevelop.Database.Sql.Firebird.mdp: Don't unnecessarily local-copy + project references. + +2007-09-21 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Firebird.addin.xml: Bump MD version. + +2007-07-10 Ben Motmans <ben.motmans@gmail.com> + + * FirebirdConnectionProvider.cs: set IsConnectionError property + +2007-07-05 Ben Motmans <ben.motmans@gmail.com> + + * FirebirdConnectionProvider.cs: ExecuteQueryAsDataSet and ExecuteQueryAsDataTable implementation + * FirebirdDbFactory.cs: specified the ISqlDialect and added default connection settings + +2007-07-02 Ben Motmans <ben.motmans@gmail.com> + + * FirebirdSchemaProvider.cs: + Fixed several compilation issues + Added Close () statements when the IDataReader is no longer needed + +2007-07-01 Ben Motmans <ben.motmans@gmail.com> + + * FirebirdSchemaProvider.cs: + * FirebirdDbFactory.cs: + * FirebirdConnectionProvider.cs: + Imported original code and splitted in 3 classes + Use of custom sql queries instead of GetSchema method to get more information + Implementation of GetViewColumns, GetProcedures, GetProcedureColumns, GetProcedureParameters, + GetUsers and GetTriggers methods diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/FirebirdConnectionProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/FirebirdConnectionProvider.cs new file mode 100644 index 0000000000..4202ef8a1e --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/FirebirdConnectionProvider.cs @@ -0,0 +1,110 @@ +// +// Authors: +// Christian Hergert <chris@mosaix.net> +// Daniel Morgan <danielmorgan@verizon.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc. +// Copyright (C) 2005 Daniel Morgan
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using FirebirdSql.Data.Firebird;
+using System.Collections.Generic;
+
namespace MonoDevelop.Database.Sql
+{
+ public class FirebirdConnectionProvider : AbstractConnectionProvider
+ {
+ public FirebirdConnectionProvider (IDbFactory factory, ConnectionSettings settings)
+ : base (factory, settings)
+ {
+ } + + public override DataSet ExecuteQueryAsDataSet (string sql) + { + if (String.IsNullOrEmpty ("sql")) + throw new ArgumentException ("sql"); + + DataSet set = new DataSet (); + using (IDbCommand command = CreateCommand (sql)) { + using (FbDataAdapter adapter = new FbDataAdapter (command as FbCommand)) { + try { + adapter.Fill (set); + } catch { + } finally { + command.Connection.Close (); + } + } + } + return set; + } + + public override DataTable ExecuteQueryAsDataTable (string sql) + { + if (String.IsNullOrEmpty ("sql")) + throw new ArgumentException ("sql"); + + DataTable table = new DataTable (); + using (IDbCommand command = CreateCommand (sql)) { + using (FbDataAdapter adapter = new FbDataAdapter (command as FbCommand)) { + try { + adapter.Fill (table); + } catch { + } finally { + command.Connection.Close (); + } + } + } + return table; + }
+
+ public override IDbConnection Open (out string errorMessage)
+ {
+ FbConnectionStringBuilder builder = null;
+ try {
+ if (settings.UseConnectionString) {
+ builder = new FbConnectionStringBuilder (settings.ConnectionString);
+ } else {
+ builder = new FbConnectionStringBuilder (); + builder.Database = settings.Database;
+ builder.UserID = settings.Username;
+ builder.Password = settings.Password;
builder.Port = settings.Port; + builder.DataSource = settings.Server;
+ }
+ builder.Pooling = settings.EnablePooling; + builder.MinPoolSize = settings.MinPoolSize; + builder.MaxPoolSize = settings.MaxPoolSize;
+ connection = new FbConnection (builder.ToString ());
+ connection.Open ();
+
+ errorMessage = String.Empty; + isConnectionError = false;
+ return connection;
+ } catch { + isConnectionError = true;
+ errorMessage = String.Format ("Unable to connect. (CS={0})", builder == null ? "NULL" : builder.ToString ());
+ return null;
+ }
+ }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/FirebirdDbFactory.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/FirebirdDbFactory.cs new file mode 100644 index 0000000000..df2ca56d53 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/FirebirdDbFactory.cs @@ -0,0 +1,73 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic;
+
namespace MonoDevelop.Database.Sql
+{
+ public class FirebirdDbFactory : IDbFactory
+ { + private ISqlDialect dialect; + + public string Identifier { + get { return "FirebirdSql.Data.Firebird"; } + } +
+ public string Name { + get { return "Firebird database (Incomplete)"; } + } + + public ISqlDialect Dialect { + get { + if (dialect == null) + dialect = new Sql99Dialect ("\"", "@"); + return dialect; + } + } + + public IConnectionProvider CreateConnectionProvider (ConnectionSettings settings) + { + return new FirebirdConnectionProvider (this, settings); + } + + public ISchemaProvider CreateSchemaProvider (IConnectionProvider connectionProvider) + { + return new FirebirdSchemaProvider (connectionProvider); + } + + public ConnectionSettings GetDefaultConnectionSettings () + { + ConnectionSettings settings = new ConnectionSettings (); + settings.ProviderIdentifier = Identifier; + settings.Server = "localhost"; + settings.Username = "firebird"; + settings.Password = String.Empty; + settings.Database = String.Empty; + settings.Port = 0; //FIXME: what is the default firebird port? + return settings; + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/FirebirdSchemaProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/FirebirdSchemaProvider.cs new file mode 100644 index 0000000000..2ad6a270d9 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/FirebirdSchemaProvider.cs @@ -0,0 +1,379 @@ +// +// Authors: +// Christian Hergert <chris@mosaix.net> +// Daniel Morgan <danielmorgan@verizon.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc. +// Copyright (C) 2005 Daniel Morgan
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using FirebirdSql.Data.Firebird;
+using System.Collections.Generic;
+
namespace MonoDevelop.Database.Sql
+{ + // see: + // http://firebird.sourceforge.net/index.php?op=devel&sub=netprovider&id=examples + // http://www.alberton.info/firebird_sql_meta_info.html
+ public class FirebirdSchemaProvider : AbstractSchemaProvider
+ {
+ public FirebirdSchemaProvider (IConnectionProvider connectionProvider)
+ : base (connectionProvider)
+ {
+ }
+
+ public override bool SupportsSchemaType (Type type)
+ {
+ if (type == typeof(TableSchema)) + return true; + else if (type == typeof(ViewSchema)) + return true; + else if (type == typeof(ProcedureSchema)) + return true; + else if (type == typeof(AggregateSchema)) + return true; + else if (type == typeof(GroupSchema)) + return true; + else if (type == typeof(UserSchema)) + return true; + else if (type == typeof(LanguageSchema)) + return true; + else if (type == typeof(OperatorSchema)) + return true; + else if (type == typeof(RoleSchema)) + return true; + else if (type == typeof(SequenceSchema)) + return true; + else if (type == typeof(DataTypeSchema)) + return true; + else if (type == typeof(TriggerSchema)) + return true; + else if (type == typeof(ColumnSchema)) + return true; + else if (type == typeof(ConstraintSchema)) + return true; + else if (type == typeof(RuleSchema)) + return true; + else + return false;
+ }
+
+ public override ICollection<TableSchema> GetTables ()
+ {
+ CheckConnectionState ();
+ List<TableSchema> tables = new List<TableSchema> ();
+
+ IDbCommand command = connectionProvider.CreateCommand ( + "SELECT RDB$RELATION_NAME, RDB$SYSTEM_FLAG, RDB$OWNER_NAME, RDB$DESCRIPTION FROM RDB$RELATIONS "+ + "WHERE RDB$VIEW_BLR IS NULL;" + ); +
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ TableSchema table = new TableSchema (this);
+
+ table.Name = r.GetString (0); + table.IsSystemTable = (!r.IsDBNull (1) && r.GetInt32 (1) != 0);
+ table.OwnerName = r.GetString (2);
+ table.Comment = r.GetString (3);
+
+ tables.Add (table);
+ } + r.Close ();
+ } + connectionProvider.Close (command.Connection);
+ }
+
+ return tables;
+ }
+
+ public override ICollection<ColumnSchema> GetTableColumns (TableSchema table)
+ {
+ return GetTableOrViewColumns (table.Name);
+ }
+
+ public override ICollection<ViewSchema> GetViews ()
+ {
+ CheckConnectionState ();
+ List<ViewSchema> views = new List<ViewSchema> (); +
+ IDbCommand command = connectionProvider.CreateCommand ( + "SELECT RDB$RELATION_NAME, RDB$SYSTEM_FLAG, RDB$OWNER_NAME, RDB$DESCRIPTION, RDB$VIEW_SOURCE FROM RDB$RELATIONS "+ + "WHERE RDB$VIEW_SOURCE IS NOT NULL;" + );
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ViewSchema view = new ViewSchema (this);
+
+ view.Name = r.GetString (0); + view.IsSystemView = (!r.IsDBNull (1) && r.GetInt32 (1) != 0);
+ view.OwnerName = r.GetString (2);
+ view.Comment = r.GetString (3); + //TODO: view.Definition = 4 (ascii blob) +
+ views.Add (view);
+ } + r.Close ();
+ } + connectionProvider.Close (command.Connection);
+ }
+ return views;
+ }
+
+ public override ICollection<ColumnSchema> GetViewColumns (ViewSchema view)
+ {
+ return GetTableOrViewColumns (view.Name);
+ }
+
+ public override ICollection<ProcedureSchema> GetProcedures ()
+ {
+ CheckConnectionState ();
+ List<ProcedureSchema> procedures = new List<ProcedureSchema> (); +
+ IDbCommand command = connectionProvider.CreateCommand ( + "SELECT RDB$PROCEDURE_NAME, RDB$SYSTEM_FLAG, RDB$OWNER_NAME, RDB$DESCRIPTION, RDB$PROCEDURE_SOURCE FROM RDB$PROCEDURES;" + );
+
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ProcedureSchema procedure = new ProcedureSchema (this); + + procedure.Name = r.GetString (0); + procedure.IsSystemProcedure = (!r.IsDBNull (1) && r.GetInt32 (1) != 0);
+ procedure.OwnerName = r.GetString (2);
+ procedure.Comment = r.GetString (3); + //TODO: procedure.Definition = 4 (ascii blob)
+
+ procedures.Add (procedure);
+ } + r.Close ();
+ } + connectionProvider.Close (command.Connection);
+ }
+
+ return procedures;
+ }
+
+ public override ICollection<ColumnSchema> GetProcedureColumns (ProcedureSchema procedure)
+ {
+ CheckConnectionState ();
+ List<ColumnSchema> columns = new List<ColumnSchema> ();
+
+ IDbCommand command = connectionProvider.CreateCommand (
+ "SELECT RDB$PARAMETER_NAME, RDB$PARAMETER_NUMBER, RDB$DESCRIPTION, RDB$SYSTEM_FLAG " + + "FROM RDB$PROCEDURE_PARAMETERS " + + "WHERE RDB$PROCEDURE_NAME = '" + procedure.Name + "' " + + "AND RDB$PARAMETER_TYPE = 1 " + + "ORDER BY 2;"
+ );
+
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) { + ColumnSchema column = new ColumnSchema (this);
+ + column.Name = r.GetString (0);
+ column.OwnerName = procedure.Name; + column.Comment = r.GetString (2);
+ //TODO: data type
+
+ columns.Add (column);
+ } + r.Close ();
+ } + connectionProvider.Close (command.Connection);
+ }
+
+ return columns;
+ }
+
+ public override ICollection<ParameterSchema> GetProcedureParameters (ProcedureSchema procedure)
+ {
+ CheckConnectionState ();
+ List<ParameterSchema> parameters = new List<ParameterSchema> ();
+
+ IDbCommand command = connectionProvider.CreateCommand (
+ "SELECT RDB$PARAMETER_NAME, RDB$PARAMETER_NUMBER, RDB$DESCRIPTION, RDB$SYSTEM_FLAG " + + "FROM RDB$PROCEDURE_PARAMETERS " + + "WHERE RDB$PROCEDURE_NAME = '" + procedure.Name + "' " + + "AND RDB$PARAMETER_TYPE = 0 " + + "ORDER BY 2;"
+ );
+
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) { + ParameterSchema parameter = new ParameterSchema (this);
+ + parameter.Name = r.GetString (0);
+ parameter.OwnerName = procedure.Name; + parameter.Comment = r.GetString (2);
+ //TODO: data type
+
+ parameters.Add (parameter);
+ } + r.Close ();
+ } + connectionProvider.Close (command.Connection);
+ }
+
+ return parameters;
+ }
+ + //TODO:
+ public override ICollection<ConstraintSchema> GetTableConstraints (TableSchema table)
+ {
+ CheckConnectionState ();
+ List<ConstraintSchema> constraints = new List<ConstraintSchema> ();
+
+ IDbCommand command = connectionProvider.CreateCommand ("SHOW TABLE STATUS FROM `" + table.OwnerName + "`;");
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+// ConstraintSchema constraint = new ConstraintSchema (this);
+// constraint.PrimaryKey = pkColumn;
+// constraint.ForeignKey = fkColumn;
+//
+// constraints.Add (constraint); + r.Close ();
+ } + connectionProvider.Close (command.Connection);
+ }
+
+ return constraints;
+ }
+
+ public override ICollection<UserSchema> GetUsers ()
+ {
+ CheckConnectionState ();
+ List<UserSchema> users = new List<UserSchema> (); +
+ IDbCommand command = connectionProvider.CreateCommand ("SELECT DISTINCT RDB$USER FROM RDB$USER_PRIVILEGES;");
+ using (command) {
+ using (IDataReader r = command.ExecuteReader ()) {
+ while (r.Read ()) {
+ UserSchema user = new UserSchema (this);
+ user.Name = r.GetString (0);
+ users.Add (user);
+ }
+ r.Close ();
+ } + connectionProvider.Close (command.Connection);
+ }
+
+ return users;
+ } + + public override ICollection<TriggerSchema> GetTriggers ()
+ { + CheckConnectionState ();
+ List<TriggerSchema> triggers = new List<TriggerSchema> (); +
+ IDbCommand command = connectionProvider.CreateCommand ("SELECT RDB$TRIGGER_NAME, RDB$RELATION_NAME, RDB$TRIGGER_TYPE FROM RDB$TRIGGERS;");
+ using (command) {
+ using (IDataReader r = command.ExecuteReader ()) {
+ while (r.Read ()) {
+ TriggerSchema trigger = new TriggerSchema (this);
+ trigger.Name = r.GetString (0); + //TODO: table and type
+ triggers.Add (trigger);
+ }
+ r.Close ();
+ } + connectionProvider.Close (command.Connection);
+ }
+
+ return triggers;
+ }
+
+ //TODO:
+ public override DataTypeSchema GetDataType (string name)
+ {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+ name = name.ToUpper ();
+
+ DataTypeSchema dts = new DataTypeSchema (this);
+ dts.Name = name;
+ switch (name) {
+ //TODO: IMPLEMENT
+ case "":
+ break;
+ default:
+ dts = null; + break;
+ }
+
+ return dts;
+ } + + private ICollection<ColumnSchema> GetTableOrViewColumns (string name)
+ {
+ CheckConnectionState ();
+ List<ColumnSchema> columns = new List<ColumnSchema> ();
+
+ IDbCommand command = connectionProvider.CreateCommand ( + "SELECT r.RDB$FIELD_NAME AS field_name, r.RDB$DESCRIPTION AS field_description, " + + "r.RDB$DEFAULT_VALUE AS field_default_value, r.RDB$NULL_FLAG AS field_not_null_constraint, " + + "f.RDB$FIELD_LENGTH AS field_length, f.RDB$FIELD_PRECISION AS field_precision, " + + "f.RDB$FIELD_SCALE AS field_scale, " + + "CASE f.RDB$FIELD_TYPE WHEN 261 THEN 'BLOB' WHEN 14 THEN 'CHAR' WHEN 40 THEN 'CSTRING' " + + "WHEN 11 THEN 'D_FLOAT' WHEN 27 THEN 'DOUBLE' WHEN 10 THEN 'FLOAT' WHEN 16 THEN 'INT64' " + + "WHEN 8 THEN 'INTEGER' WHEN 9 THEN 'QUAD' WHEN 7 THEN 'SMALLINT' WHEN 12 THEN 'DATE' " + + "WHEN 13 THEN 'TIME' WHEN 35 THEN 'TIMESTAMP' WHEN 37 THEN 'VARCHAR' ELSE 'UNKNOWN' " + + "END AS field_type, f.RDB$FIELD_SUB_TYPE AS field_subtype, " + + "coll.RDB$COLLATION_NAME AS field_collation, cset.RDB$CHARACTER_SET_NAME AS field_charset " + + "FROM RDB$RELATION_FIELDS r LEFT JOIN RDB$FIELDS f ON r.RDB$FIELD_SOURCE = f.RDB$FIELD_NAME " + + "LEFT JOIN RDB$COLLATIONS coll ON f.RDB$COLLATION_ID = coll.RDB$COLLATION_ID " + + "LEFT JOIN RDB$CHARACTER_SETS cset ON f.RDB$CHARACTER_SET_ID = cset.RDB$CHARACTER_SET_ID " + + "WHERE r.RDB$RELATION_NAME='" + name + "' ORDER BY r.RDB$FIELD_POSITION;" + );
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ColumnSchema column = new ColumnSchema (this);
+
+ column.Name = r.GetString (0);
+ column.DataTypeName = r.GetString (8);
+ column.NotNull = (!r.IsDBNull (3) && r.GetInt32 (3) == 1);
+ column.Default = r.GetString (2);
+ column.Comment = r.GetString (1);
+ column.OwnerName = name; + column.Length = r.GetInt32 (4); + column.Precision = r.GetInt32 (5); + column.Scale = r.GetInt32 (6);
+
+ columns.Add (column);
+ } + r.Close ();
+ }; + connectionProvider.Close (command.Connection);
+ }
+
+ return columns;
+ }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/MonoDevelop.Database.Sql.Firebird.addin.xml b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/MonoDevelop.Database.Sql.Firebird.addin.xml new file mode 100644 index 0000000000..173307e3f2 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/MonoDevelop.Database.Sql.Firebird.addin.xml @@ -0,0 +1,21 @@ +<Addin id = "MonoDevelop.Database.Sql.Firebird" + namespace = "MonoDevelop" + name = "Firebird provider for Mono Data Sql" + author = "Christian Hergert, Daniel Morgan, Ben Motmans" + copyright = "MIT X11" + url = "http://www.monodevelop.com" + description = "Database Module" + version = "0.17.0"> + + <Runtime> + <Import assembly="MonoDevelop.Database.Sql.Firebird.dll"/> + </Runtime> + + <Dependencies> + <Addin id="MonoDevelop.Database.Sql" version="0.17.0"/> + </Dependencies> + + <Extension path = "/Mono/Data/Sql"> + <Class id = "Firebird" class = "MonoDevelop.Database.Sql.FirebirdDbFactory"/> + </Extension> +</Addin>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/MonoDevelop.Database.Sql.Firebird.mdp b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/MonoDevelop.Database.Sql.Firebird.mdp new file mode 100644 index 0000000000..e3ba45bbf2 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Firebird/MonoDevelop.Database.Sql.Firebird.mdp @@ -0,0 +1,29 @@ +<Project name="MonoDevelop.Database.Sql.Firebird" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql.Firebird" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql.Firebird" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="FirebirdConnectionProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="FirebirdSchemaProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="MonoDevelop.Database.Sql.Firebird.addin.xml" subtype="Code" buildaction="FileCopy" /> + <File name="FirebirdDbFactory.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema" subtype="Directory" buildaction="Compile" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Assembly" localcopy="True" refto="../../contrib/FirebirdSql.Data.Firebird.dll" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Sql" /> + </References> +</Project>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/AssemblyInfo.cs.in b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/AssemblyInfo.cs.in new file mode 100644 index 0000000000..c4c6648eb1 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/AssemblyInfo.cs.in @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("MonoDevelop.Database.Sql.MySql")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("http://www.monodevelop.com")] +[assembly: AssemblyCopyright("MIT X11 - Christian Hergert, Ben Motmans")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: AssemblyVersion("@ASSEMBLY_VERSION@")] + +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/ChangeLog b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/ChangeLog new file mode 100644 index 0000000000..383a220867 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/ChangeLog @@ -0,0 +1,121 @@ +2007-10-29 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.MySql.addin.xml: Bump MD version. + +2007-10-23 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.MySql.mdp: Project file names updated by change + in MD path functions. + +2007-10-16 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.MySql.mdp: Fix required GTK# version. + +2007-09-26 Michael Hutchinson <mhutchinson@novell.com> + + * Makefile.am: Don't deploy .addin.xml file. + * MonoDevelop.Database.Sql.MySql.mdp: Don't unnecessarily local-copy project + references. Don't sync EXTRA_DIST with deploy files. Add Makefile.am to + file list. + +2007-09-21 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.MySql.addin.xml: Bump MD version. + +2007-09-20 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: removed incorrect references + +2007-09-20 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: changed reference to contrib/MySql + +2007-09-16 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: link to the correct Mono.Addins dll + +2007-09-07 Ben Motmans <ben.motmans@gmail.com> + + * MySqlSchemaProvider.cs, MySqlDbFactory.cs, + MonoDevelop.Database.Sql.MySql.addin.xml: improved capabilities system + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am, MonoDevelop.Database.Sql.MySql.mdp: use project references + instead of assembly references + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: updated makefile + +2007-08-03 Ben Motmans <ben.motmans@gmail.com> + + * MySqlConnectionProvider.cs: added support for an error message + +2007-08-02 Ben Motmans <ben.motmans@gmail.com> + + * MySqlSchemaProvider.cs: also create triggers in the create table method + +2007-08-01 Ben Motmans <ben.motmans@gmail.com> + + * MySqlSchemaProvider.cs: Catch exceptions and notify the user and various + small bugfixes + +2007-07-31 Ben Motmans <ben.motmans@gmail.com> + + * MySqlDbFactory.cs, MySqlGuiProvider.cs: Added a GuiProvider + * MySqlSchemaProvider.cs: Implemented CreateTable + +2007-07-25 Ben Motmans <ben.motmans@gmail.com> + + * MySqlPooledDbConnection.cs: expose the GetSchema method of the internal connection + * MySqlDbFactory.cs, MySqlSchemaProvider.cs: improved metadata support + +2007-07-18 Ben Motmans <ben.motmans@gmail.com> + + * MySqlSchemaProvider.cs: SupportsSchemaOperation implementation, use of strongly typed + collections, Drop* and Rename* implementations + +2007-07-17 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: initial makefile + * MySqlDbFactory.cs: implemented methods required for the connection settings dialog + * MySqlSchemaProvider.cs: implemented GetDataType method + +2007-07-15 Ben Motmans <ben.motmans@gmail.com> + + * MySqlDialect.cs: dialect implementation with keyword detection + * MySqlDbFactory.cs: use MySqlDialect instead of the obsolete Sql99Dialect + +2007-07-14 Ben Motmans <ben.motmans@gmail.com> + + * MySqlConnectionProvider.cs, MySqlDbFactory.cs, MySqlSchemaProvider.cs: small changes + to reflect API changes + * MySqlPooledDbConnection.cs: implementation of ConnectionPool aware connection + + +2007-07-10 Ben Motmans <ben.motmans@gmail.com> + + * MySqlConnectionProvider.cs: set IsConnectionError property + +2007-07-05 Ben Motmans <ben.motmans@gmail.com> + + * MySqlConnectionProvider.cs: ExecuteQueryAsDataSet and ExecuteQueryAsDataTable implementation + * MySqlDbFactory.cs: specified the ISqlDialect and added default connection settings + * Mono.Data.Sql.MySql.mdp: switched from the old ByteFX.Data provider to the new MySql.Data + +2007-07-02 Ben Motmans <ben.motmans@gmail.com> + + * MySqlSchemaProvider.cs: + Fixed several compilation issues + Added Close () statements when the IDataReader is no longer needed + +2007-07-01 Ben Motmans <ben.motmans@gmail.com> + + * MySqlSchemaProvider.cs: + * MySqlDbFactory.cs: + * MySqlConnectionProvider.cs: + Imported original code and splitted in 3 classes + GetDatabases, GetTableConstraints, GetViews, GetProcedures, GetViewColumns, GetProcedureColumns implementation + improved support for MySql 5.x for the GetTables method + updated sql statements to allow lazy loading diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/Makefile.am b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/Makefile.am new file mode 100644 index 0000000000..a995d76b7b --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/Makefile.am @@ -0,0 +1,51 @@ +ADDIN_BUILD = $(top_builddir)/build/AddIns/MonoDevelop.Database +ASSEMBLY = $(ADDIN_BUILD)/MonoDevelop.Database.Sql.MySql.dll +REFS = \ + $(GTK_SHARP_LIBS) \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Components.dll \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Designer.dll \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Sql.dll \ + -r:$(top_builddir)/build/bin/Mono.Addins.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Components.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.Gui.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Ide.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Projects.dll \ + -r:$(top_srcdir)/contrib/MySql/MySql.Data.dll \ + -r:System \ + -r:System.Data + +FILES = \ + MySqlConnectionProvider.cs \ + MySqlDbFactory.cs \ + MySqlDialect.cs \ + MySqlGuiProvider.cs \ + MySqlPooledDbConnection.cs \ + MySqlSchemaProvider.cs + +MYSQL_FILES = \ + MySql.Data.dll + +RES = MonoDevelop.Database.Sql.MySql.addin.xml + +SRC_MYSQL_FILES = $(addprefix $(top_srcdir)/contrib/MySql/, $(MYSQL_FILES)) +BUILD_MYSQL_FILES = $(addprefix $(ADDIN_BUILD)/, $(notdir $(MYSQL_FILES))) + +all: $(ASSEMBLY) $(BUILD_MYSQL_FILES) + +$(BUILD_MYSQL_FILES): $(SRC_MYSQL_FILES) + mkdir -p $(ADDIN_BUILD) + cp $(SRC_MYSQL_FILES) $(ADDIN_BUILD)/. + +$(ASSEMBLY): $(FILES) $(build_resources) + mkdir -p $(ADDIN_BUILD) + $(CSC) $(CSC_FLAGS) $(REFS) $(build_resources:%=/resource:%) $(build_sources) -out:$@ -target:library + + +assemblydir = $(MD_ADDIN_DIR)/MonoDevelop.Database +assembly_DATA = $(ASSEMBLY) $(BUILD_MYSQL_FILES) + +CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb $(BUILD_MYSQL_FILES) +EXTRA_DIST = $(FILES) $(RES) $(SRC_MYSQL_FILES) + +include $(top_srcdir)/Makefile.include diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MonoDevelop.Database.Sql.MySql.addin.xml b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MonoDevelop.Database.Sql.MySql.addin.xml new file mode 100644 index 0000000000..9f877db2fe --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MonoDevelop.Database.Sql.MySql.addin.xml @@ -0,0 +1,65 @@ +<Addin id = "Database.Sql.MySql" + namespace = "MonoDevelop" + name = "MySql provider for Mono Data Sql" + author = "Christian Hergert, Ben Motmans" + copyright = "MIT X11" + url = "http://www.monodevelop.com" + description = "Database Module" + version = "0.17.0"> + + <Runtime> + <Import assembly="MonoDevelop.Database.Sql.MySql.dll"/> + </Runtime> + + <Dependencies> + <Addin id="Core" version="0.17.0"/> + <Addin id="Core.Gui" version="0.17.0"/> + <Addin id="Ide" version="0.17.0"/> + <Addin id="Database.Sql" version="0.17.0"/> + <Addin id="Database.Components" version="0.17.0"/> + <Addin id="Database.Designer" version="0.17.0"/> + </Dependencies> + + <Extension path = "/MonoDevelop/Database/Sql"> + <DatabaseFactory id = "MySql" class = "MonoDevelop.Database.Sql.MySqlDbFactory"> + <!-- action flags --> + <Actions category="Database" flags="All" /> + <Actions category="Table" flags="Create,Drop,Rename,Schema" /> + <Actions category="View" flags="All" /> + <Actions category="Procedure" flags="All" /> + <Actions category="TableColumn" flags="All" /> + <Actions category="Parameter" flags="Schema" /> + <Actions category="Trigger" flags="All" /> + <Actions category="PrimaryKeyConstraint" flags="Create,Drop,Rename,Schema" /> + <Actions category="ForeignKeyConstraint" flags="Create,Drop,Rename,Schema" /> + <Actions category="CheckConstraint" flags="Create,Drop,Rename,Schema" /> + <Actions category="UniqueConstraint" flags="Create,Drop,Rename,Schema" /> + <Actions category="User" flags="Schema" /> + + <!-- ConnectionSettings capabilities --> + <Capabilities category="ConnectionSettings" action="Schema" flags="Username,Password,Server,Port,ListDatabases" /> + <!-- table capabilities --> + <Capabilities category="Table" action="All" flags="Name,Definition,Schema,IsSystem,Columns,Constraints,Trigger" /> + <Capabilities category="Table" action="Alter" flags="AppendConstraint,InsertConstraint,RemoveConstraint,AppendTrigger,InsertTrigger,RemoveTrigger,AppendColumn,InsertColumn,RemoveColumn" /> + <!-- Table Column capabilities --> + <Capabilities category="TableColumn" action="All" flags="Name,Definition,Schema,DataType,DefaultValue,Nullable,Position,Constraints" /> + <Capabilities category="TableColumn" action="Alter" flags="AppendConstraint,InsertConstraint,RemoveConstraint" /> + <!-- Procedure capabilities --> + <Capabilities category="Procedure" action="All" flags="Name,Definition,Schema,IsSystem" /> + <Capabilities category="Procedure" action="Schema" flags="Parameters" /> + <Capabilities category="Procedure" action="Alter" flags="InsertParameter,AppendParameter,RemoveParameter" /> + <!-- View capabilities --> + <Capabilities category="View" action="All" flags="Name,Definition,Schema,Statement,IsSystem" /> + <!-- Trigger capabilities --> + <Capabilities category="Trigger" action="All" flags="Name,Definition,Schema,TableName,TriggerType,TriggerEvent,TriggerFireType,Position,IsActive,Source" /> + <!-- PrimaryKeyConstraint capabilities --> + <Capabilities category="PrimaryKeyConstraint" action="All" flags="Name,Columns,IsColumnConstraint" /> + <!-- ForeignKeyConstraint capabilities --> + <Capabilities category="ForeignKeyConstraint" action="All" flags="Name,Columns,IsColumnConstraint,ReferenceTable,ReferenceColumns,Restrict,Cascade,SetNull,NoAction" /> + <!-- CheckConstraint capabilities --> + <Capabilities category="CheckConstraint" action="All" flags="Name,Columns,IsColumnConstraint,Source" /> + <!-- UniqueConstraint capabilities --> + <Capabilities category="UniqueConstraint" action="All" flags="Name,Columns,IsColumnConstraint" /> + </DatabaseFactory> + </Extension> +</Addin> diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MonoDevelop.Database.Sql.MySql.mdp b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MonoDevelop.Database.Sql.MySql.mdp new file mode 100644 index 0000000000..dfe93fb3c5 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MonoDevelop.Database.Sql.MySql.mdp @@ -0,0 +1,53 @@ +<Project name="MonoDevelop.Database.Sql.MySql" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql.MySql" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql.MySql" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="MySqlConnectionProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="MySqlSchemaProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="MonoDevelop.Database.Sql.MySql.addin.xml" subtype="Code" buildaction="EmbedAsResource" /> + <File name="MySqlDbFactory.cs" subtype="Code" buildaction="Compile" /> + <File name="MySqlPooledDbConnection.cs" subtype="Code" buildaction="Compile" /> + <File name="MySqlDialect.cs" subtype="Code" buildaction="Compile" /> + <File name="MySqlGuiProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="Makefile.am" subtype="Code" buildaction="Nothing" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Sql" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Components" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Designer" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core.Gui" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Components" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Ide" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Projects" /> + <ProjectReference type="Assembly" localcopy="True" refto="../../../contrib/MySql/MySql.Data.dll" /> + <ProjectReference type="Project" localcopy="False" refto="Mono.Addins" /> + <ProjectReference type="Gac" localcopy="True" refto="pango-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="atk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + </References> + <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am" BuildTargetName="" CleanTargetName="" SyncReferences="True" IsAutotoolsProject="True" RelativeConfigureInPath="../../../"> + <BuildFilesVar Sync="True" Name="FILES" /> + <DeployFilesVar /> + <ResourcesVar Sync="True" Name="RES" /> + <OthersVar /> + <GacRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <AsmRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <ProjectRefVar Sync="True" Name="REFS" Prefix="-r:" /> + </MonoDevelop.Autotools.MakefileInfo> +</Project>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlConnectionProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlConnectionProvider.cs new file mode 100644 index 0000000000..03c040ec44 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlConnectionProvider.cs @@ -0,0 +1,62 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Daniel Morgan <danielmorgan@verizon.net>
+// Sureshkumar T <tsureshkumar@novell.com>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using MySql.Data.MySqlClient;
+using System.Collections.Generic;
+
namespace MonoDevelop.Database.Sql
+{
+ public class MySqlConnectionProvider : AbstractConnectionProvider
+ {
+ public override IPooledDbConnection CreateConnection (IConnectionPool pool, DatabaseConnectionSettings settings, out string error)
+ { + string connStr = null;
+ try {
+ if (settings.UseConnectionString) { + connStr = settings.ConnectionString;
+ } else { + //"Server=Server;Port=1234;Database=Test;Uid=UserName;Pwd=asdasd;"
+ //Default port is 3306. Enter value -1 to use a named pipe connection. + connStr = String.Format ("Server={0};Port={1};Database={2};Uid={3};Pwd={4};", + settings.Server, settings.Port, settings.Database, settings.Username, settings.Password);
+ } + connStr = SetConnectionStringParameter (connStr, String.Empty, "Pooling", "false");
+ MySqlConnection connection = new MySqlConnection (connStr);
+ connection.Open ();
+ + error = null;
+ return new MySqlPooledDbConnection (pool, connection);
+ } catch (Exception e) { + error = e.Message;
+ return null;
+ }
+ }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlDbFactory.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlDbFactory.cs new file mode 100644 index 0000000000..e2dd5d0838 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlDbFactory.cs @@ -0,0 +1,95 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+ +using System;
+using System.Data;
+using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Database.Components;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class MySqlDbFactory : AbstractDbFactory
+ { + private ISqlDialect dialect; + private IConnectionProvider connectionProvider; + private IGuiProvider guiProvider; + + public override string Identifier { + get { return "MySql.Data.MySqlClient"; } + } +
+ public override string Name { + get { return "MySql database"; } + } + + public override ISqlDialect Dialect { + get { + if (dialect == null) + dialect = new MySqlDialect (); + return dialect; + } + } + + public override IConnectionProvider ConnectionProvider { + get { + if (connectionProvider == null) + connectionProvider = new MySqlConnectionProvider (); + return connectionProvider; + } + } + + public override IGuiProvider GuiProvider { + get { + if (guiProvider == null) + guiProvider = new MySqlGuiProvider (); + return guiProvider; + } + } + + public override IConnectionPool CreateConnectionPool (DatabaseConnectionContext context) + { + return new DefaultConnectionPool (this, ConnectionProvider, context); + } + + public override ISchemaProvider CreateSchemaProvider (IConnectionPool connectionPool) + { + return new MySqlSchemaProvider (connectionPool); + } + + public override DatabaseConnectionSettings GetDefaultConnectionSettings () + { + DatabaseConnectionSettings settings = new DatabaseConnectionSettings (); + settings.ProviderIdentifier = Identifier; + settings.Server = "localhost"; + settings.Port = 3306; + settings.Username = "root"; + settings.MaxPoolSize = 5; + + return settings; + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlDialect.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlDialect.cs new file mode 100644 index 0000000000..2b1e19fda6 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlDialect.cs @@ -0,0 +1,137 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic; +
namespace MonoDevelop.Database.Sql
+{
+ public class MySqlDialect : AbstractSqlDialect
+ { + public override string QuoteIdentifier (string identifier) + { + if (identifier == null) + throw new ArgumentNullException ("identifier"); + + if (IsReservedWord (identifier) || identifier.Contains (" ")) + return String.Concat ('`', identifier, '`'); + return identifier; + } + + public override string MarkAsParameter (string identifier) + { + if (identifier == null) + throw new ArgumentNullException ("identifier"); + + return "?" + identifier; + } + + //http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html + protected virtual bool IsReservedWord (string word) + { + word = word.ToUpper (); + + switch (word) { + case "ADD": case "ALL": case "ALTER": case "ANALYZE": + case "AND": case "AS": case "ASC": + case "ASENSITIVE": case "BEFORE": case "BETWEEN": + case "BIGINT": case "BINARY": case "BLOB": + case "BOTH": case "BY": case "CALL": + case "CASCADE": case "CASE": case "CHANGE": + case "CHAR": case "CHARACTER": case "CHECK": + case "COLLATE": case "COLUMN": case "CONDITION": + case "CONSTRAINT": case "CONTINUE": case "CONVERT": + case "CREATE": case "CROSS": case "CURRENT_DATE": + case "CURRENT_TIME": case "CURRENT_TIMESTAMP": case "CURRENT_USER": + case "CURSOR": case "DATABASE": case "DATABASES": + case "DAY_HOUR": case "DAY_MICROSECOND": case "DAY_MINUTE": + case "DAY_SECOND": case "DEC": case "DECIMAL": + case "DECLARE": case "DEFAULT": case "DELAYED": + case "DELETE": case "DESC": case "DESCRIBE": + case "DETERMINISTIC": case "DISTINCT": case "DISTINCTROW": + case "DIV": case "DOUBLE": case "DROP": + case "DUAL": case "EACH": case "ELSE": + case "ELSEIF": case "ENCLOSED": case "ESCAPED": + case "EXISTS": case "EXIT": case "EXPLAIN": + case "FALSE": case "FETCH": case "FLOAT": + case "FLOAT4": case "FLOAT8": case "FOR": + case "FORCE": case "FOREIGN": case "FROM": + case "FULLTEXT": case "GRANT": case "GROUP": + case "HAVING": case "HIGH_PRIORITY": case "HOUR_MICROSECOND": + case "HOUR_MINUTE": case "HOUR_SECOND": case "IF": + case "IGNORE": case "IN": case "INDEX": + case "INFILE": case "INNER": case "INOUT": + case "INSENSITIVE": case "INSERT": case "INT": + case "INT1": case "INT2": case "INT3": + case "INT4": case "INT8": case "INTEGER": + case "INTERVAL": case "INTO": case "IS": + case "ITERATE": case "JOIN": case "KEY": + case "KEYS": case "KILL": case "LEADING": + case "LEAVE": case "LEFT": case "LIKE": + case "LIMIT": case "LINES": case "LOAD": + case "LOCALTIME": case "LOCALTIMESTAMP": case "LOCK": + case "LONG": case "LONGBLOB": case "LONGTEXT": + case "LOOP": case "LOW_PRIORITY": case "MATCH": + case "MEDIUMBLOB": case "MEDIUMINT": case "MEDIUMTEXT": + case "MIDDLEINT": case "MINUTE_MICROSECOND": case "MINUTE_SECOND": + case "MOD": case "MODIFIES": case "NATURAL": + case "NOT": case "NO_WRITE_TO_BINLOG": case "NULL": + case "NUMERIC": case "ON": case "OPTIMIZE": + case "OPTION": case "OPTIONALLY": case "OR": + case "ORDER": case "OUT": case "OUTER": + case "OUTFILE": case "PRECISION": case "PRIMARY": + case "PROCEDURE": case "PURGE": case "RAID0": + case "READ": case "READS": case "REAL": + case "REFERENCES": case "REGEXP": case "RELEASE": + case "RENAME": case "REPEAT": case "REPLACE": + case "REQUIRE": case "RESTRICT": case "RETURN": + case "REVOKE": case "RIGHT": case "RLIKE": + case "SCHEMA": case "SCHEMAS": case "SECOND_MICROSECOND": + case "SELECT": case "SENSITIVE": case "SEPARATOR": + case "SET": case "SHOW": case "SMALLINT": + case "SONAME": case "SPATIAL": case "SPECIFIC": + case "SQL": case "SQLEXCEPTION": case "SQLSTATE": + case "SQLWARNING": case "SQL_BIG_RESULT": case "SQL_CALC_FOUND_ROWS": + case "SQL_SMALL_RESULT": case "SSL": case "STARTING": + case "STRAIGHT_JOIN": case "TABLE": case "TERMINATED": + case "THEN": case "TINYBLOB": case "TINYINT": + case "TINYTEXT": case "TO": case "TRAILING": + case "TRIGGER": case "TRUE": case "UNDO": + case "UNION": case "UNIQUE": case "UNLOCK": + case "UNSIGNED": case "UPDATE": case "USAGE": + case "USE": case "USING": case "UTC_DATE": + case "UTC_TIME": case "UTC_TIMESTAMP": case "VALUES": + case "VARBINARY": case "VARCHAR": case "VARCHARACTER": + case "VARYING": case "WHEN": case "WHERE": + case "WHILE": case "WITH": case "WRITE": + case "X509": case "XOR": case "YEAR_MONTH": + case "ZEROFILL": + return true; + default: + return false; + } + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlGuiProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlGuiProvider.cs new file mode 100644 index 0000000000..33428bd202 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlGuiProvider.cs @@ -0,0 +1,74 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using Gtk; +using System;
+using System.Data;
+using System.Collections.Generic; +using MonoDevelop.Database.Designer; +using MonoDevelop.Database.Components;
+
namespace MonoDevelop.Database.Sql
+{
+ public class MySqlGuiProvider : IGuiProvider
+ { + public bool ShowSelectDatabaseDialog (bool create, out string database) + { + database = null; + return false; + } + + public bool ShowTableEditorDialog (ISchemaProvider schemaProvider, TableSchema table, bool create) + { + return RunDialog (new TableEditorDialog (schemaProvider, table, create)); + } + + public bool ShowViewEditorDialog (ISchemaProvider schemaProvider, ViewSchema view, bool create) + { + return RunDialog (new ViewEditorDialog (schemaProvider, view, create)); + } + + public bool ShowProcedureEditorDialog (ISchemaProvider schemaProvider, ProcedureSchema procedure, bool create) + { + return RunDialog (new ProcedureEditorDialog (schemaProvider, procedure, create)); + } + + public bool ShowUserEditorDialog (ISchemaProvider schemaProvider, UserSchema user, bool create) + { + return RunDialog (new UserEditorDialog (schemaProvider, user, create)); + } + + private bool RunDialog (Dialog dlg) + { + bool result = false; + try { + if (dlg.Run () == (int)ResponseType.Ok) + result = true; + } finally { + dlg.Destroy (); + } + return result; + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlPooledDbConnection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlPooledDbConnection.cs new file mode 100644 index 0000000000..3bd3bd819f --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlPooledDbConnection.cs @@ -0,0 +1,81 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic; +using MySql.Data.MySqlClient;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class MySqlPooledDbConnection : AbstractPooledDbConnection
+ { + public MySqlPooledDbConnection (IConnectionPool connectionPool, IDbConnection connection) + : base (connectionPool, connection) + { + } + + public override DataSet ExecuteSet (IDbCommand command) + { + if (command == null) + throw new ArgumentException ("command"); + + DataSet set = new DataSet (); + using (command) { + using (MySqlDataAdapter adapter = new MySqlDataAdapter (command as MySqlCommand)) { + try { + adapter.Fill (set); + } catch (Exception e) { + QueryService.RaiseException (e); + } + } + } + return set; + } + + public override DataTable ExecuteTable (IDbCommand command) + { + if (command == null) + throw new ArgumentException ("command"); + + DataTable table = new DataTable (); + using (command) { + using (MySqlDataAdapter adapter = new MySqlDataAdapter (command as MySqlCommand)) { + try { + adapter.Fill (table); + } catch (Exception e) { + QueryService.RaiseException (e); + } + } + } + return table; + } + + public override DataTable GetSchema (string collectionName, params string[] restrictionValues) + { + return (connection as MySqlConnection).GetSchema (collectionName, restrictionValues); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlSchemaProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlSchemaProvider.cs new file mode 100755 index 0000000000..65c77cee26 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.MySql/MySqlSchemaProvider.cs @@ -0,0 +1,888 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Daniel Morgan <danielmorgan@verizon.net>
+// Sureshkumar T <tsureshkumar@novell.com>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Data;
+using MySql.Data.MySqlClient;
+using System.Collections.Generic; +using MonoDevelop.Core;
+
namespace MonoDevelop.Database.Sql
+{ + public class MySqlSchemaProvider : AbstractSchemaProvider
+ {
+ public MySqlSchemaProvider (IConnectionPool connectionPool)
+ : base (connectionPool)
+ {
+ }
+
+ public override DatabaseSchemaCollection GetDatabases ()
+ {
+ DatabaseSchemaCollection databases = new DatabaseSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand ("SHOW DATABASES;"); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ DatabaseSchema db = new DatabaseSchema (this);
+ db.Name = r.GetString (0);
+ databases.Add (db);
+
+ } + r.Close ();
+ }
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return databases;
+ }
+
+ // see: http://dev.mysql.com/doc/refman/5.1/en/tables-table.html + // // see: http://dev.mysql.com/doc/refman/5.1/en/show-create-table.html
+ public override TableSchemaCollection GetTables ()
+ {
+ TableSchemaCollection tables = new TableSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand ("SHOW TABLES;"); + try {
+ using (command) {
+ if (GetMainVersion (command) >= 5) {
+ //in mysql 5.x we can use an sql query to provide the comment
+ command.CommandText = "SELECT TABLE_NAME, TABLE_SCHEMA, TABLE_TYPE, TABLE_COMMENT FROM `information_schema`.`TABLES` "
+ + "WHERE TABLE_TYPE='BASE TABLE' AND TABLE_SCHEMA='"
+ + command.Connection.Database
+ + "' ORDER BY TABLE_NAME;";
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ TableSchema table = new TableSchema (this);
+
+ table.Name = r.GetString (0);
+ table.SchemaName = r.GetString (1);
+ table.Comment = r.IsDBNull (3) ? null : r.GetString (3); + + IPooledDbConnection conn2 = connectionPool.Request (); + IDbCommand command2 = conn2.CreateCommand ("SHOW CREATE TABLE `" + table.Name + "`;");
+ using (IDataReader r2 = command2.ExecuteReader()) { + r2.Read (); + table.Definition = r2.GetString (1); + } + conn2.Release ();
+
+ tables.Add (table);
+ } + r.Close ();
+ }
+ } else {
+ //use the default command for mysql 4.x and 3.23
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ TableSchema table = new TableSchema (this);
+
+ table.Name = r.GetString (0);
+ table.SchemaName = command.Connection.Database; + + IPooledDbConnection conn2 = connectionPool.Request (); + IDbCommand command2 = conn2.CreateCommand ("SHOW CREATE TABLE `" + table.Name + "`;");
+ using (IDataReader r2 = command2.ExecuteReader()) { + r2.Read (); + table.Definition = r2.GetString (1); + }
+ conn2.Release (); +
+ tables.Add (table);
+ } + r.Close ();
+ }
+ }
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return tables;
+ }
+
+ public override ColumnSchemaCollection GetTableColumns (TableSchema table)
+ {
+ ColumnSchemaCollection columns = new ColumnSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand (String.Format ("DESCRIBE {0}", table.Name)); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ColumnSchema column = new ColumnSchema (this, table); +
+ column.Name = r.GetString (0);
+ column.DataTypeName = r.GetString (1);
+ column.IsNullable = String.Compare (r.GetString (2), "YES", true) == 0;
+ column.DefaultValue = r.IsDBNull (4) ? null : r.GetString (4);
+ //TODO: if r.GetString (5) constains "auto_increment"
+ column.OwnerName = table.Name;
+
+ columns.Add (column);
+ } + r.Close ();
+ };
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return columns;
+ }
+
+ // see: http://dev.mysql.com/doc/refman/5.1/en/views-table.html
+ public override ViewSchemaCollection GetViews ()
+ {
+ ViewSchemaCollection views = new ViewSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand (
+ "SELECT TABLE_NAME, TABLE_SCHEMA FROM information_schema.VIEWS where TABLE_SCHEMA = '"
+ + ConnectionPool.ConnectionContext.ConnectionSettings.Database +
+ "' ORDER BY TABLE_NAME"
+ ); + try {
+ using (command) {
+ if (GetMainVersion (command) >= 5) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ViewSchema view = new ViewSchema (this);
+
+ view.Name = r.GetString (0);
+ view.OwnerName = r.GetString (1); + + IPooledDbConnection conn2 = connectionPool.Request (); + IDbCommand command2 = conn2.CreateCommand ("SHOW CREATE TABLE `" + view.Name + "`;");
+ using (IDataReader r2 = command2.ExecuteReader()) { + r2.Read (); + view.Definition = r2.GetString (1); + } + conn2.Release (); +
+ views.Add (view);
+ } + r.Close ();
+ }
+ } //else: do nothing, since views are only supported since mysql 5.x
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release (); +
+ return views;
+ }
+
+ public override ColumnSchemaCollection GetViewColumns (ViewSchema view)
+ {
+ ColumnSchemaCollection columns = new ColumnSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand (String.Format ("DESCRIBE {0}", view.Name)); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ColumnSchema column = new ColumnSchema (this, view);
+
+ column.Name = r.GetString (0);
+ column.DataTypeName = r.GetString (1);
+ column.IsNullable = r.IsDBNull (2);
+ column.DefaultValue = r.GetString (4);
+ column.Comment = r.GetString (5);
+ column.OwnerName = view.Name;
+
+ columns.Add (column);
+ } + r.Close ();
+ };
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return columns;
+ }
+
+ // see: http://dev.mysql.com/doc/refman/5.1/en/routines-table.html
+ public override ProcedureSchemaCollection GetProcedures ()
+ {
+ ProcedureSchemaCollection procedures = new ProcedureSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand (
+ "SELECT ROUTINE_NAME, ROUTINE_SCHEMA, ROUTINE_TYPE FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA ='"
+ + ConnectionPool.ConnectionContext.ConnectionSettings.Database +
+ "' ORDER BY ROUTINE_NAME"
+ );
+ try {
+ using (command) {
+ if (GetMainVersion (command) >= 5) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ProcedureSchema procedure = new ProcedureSchema (this);
+
+ procedure.Name = r.GetString (0);
+ procedure.OwnerName = r.GetString (1);
+ procedure.IsSystemProcedure = r.GetString (2).ToLower ().Contains ("system"); + + IPooledDbConnection conn2 = connectionPool.Request (); + IDbCommand command2 = conn2.CreateCommand ("SHOW CREATE PROCEDURE `" + procedure.Name + "`;"); + using (IDataReader r2 = command2.ExecuteReader()) { + r2.Read (); + procedure.Definition = r2.GetString (2); + }
+ conn2.Release (); +
+ procedures.Add (procedure);
+ } + r.Close ();
+ }
+ } //else: do nothing, since procedures are only supported since mysql 5.x
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return procedures;
+ }
+
+ public override ParameterSchemaCollection GetProcedureParameters (ProcedureSchema procedure)
+ {
+ ParameterSchemaCollection parameters = new ParameterSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand (
+ "SELECT param_list FROM mysql.proc where name = '" + procedure.Name + "'"
+ );
+ try {
+ using (command) {
+ if (GetMainVersion (command) >= 5) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ if (r.IsDBNull (0))
+ continue;
+
+ string[] field = Encoding.ASCII.GetString ((byte[])r.GetValue (0)).Split (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+ foreach (string chunk in field) {
+ ParameterSchema param = new ParameterSchema (this); + param.Definition = chunk;
+
+ string[] tmp = chunk.TrimStart (new char[] { ' ' }).Split (new char[] { ' ' }); + int nameIndex = 0; + if (String.Compare (tmp[0], "OUT", true) == 0) { + nameIndex = 1; + param.ParameterType = ParameterType.Out; + } else if (String.Compare (tmp[0], "INOUT", true) == 0) { + nameIndex = 1; + param.ParameterType = ParameterType.InOut; + } else { + param.ParameterType = ParameterType.In; + } +
+ param.Name = tmp[nameIndex];
+ param.OwnerName = procedure.Name;
+ param.DataTypeName = tmp[nameIndex + 1];
+
+ parameters.Add (param);
+ }
+ } + r.Close ();
+ }
+ } //else: do nothing, since procedures are only supported since mysql 5.x
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return parameters;
+ }
+
+ private static Regex constraintRegex = new Regex (@"`([\w ]+)`", RegexOptions.Compiled);
+ public override ConstraintSchemaCollection GetTableConstraints (TableSchema table)
+ {
+ ConstraintSchemaCollection constraints = new ConstraintSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand ("SHOW TABLE STATUS FROM `" + table.SchemaName + "`;"); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) { + while (r.Read ()) {
+ string[] chunks = ((string)r["Comment"]).Split (';');
+
+ //the values we are looking for are in the format (`table`) REFER `database\table2` (`table2`)
+ foreach (string chunk in chunks) {
+ if (constraintRegex.IsMatch (chunk)) {
+ MatchCollection matches = constraintRegex.Matches (chunk);
+
+ ForeignKeyConstraintSchema constraint = new ForeignKeyConstraintSchema (this);
+ constraint.ReferenceTableName = matches[1].Groups[1].ToString ();
+ constraint.Name = matches[0].Groups[1].ToString (); +
+ constraints.Add (constraint);
+ }
+ } + } + r.Close ();
+ }
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return constraints;
+ } + + public override ConstraintSchemaCollection GetColumnConstraints (TableSchema table, ColumnSchema column) + { + ConstraintSchemaCollection constraints = new ConstraintSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand (String.Format ("DESCRIBE {0}", table.Name)); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) { + if (r.IsDBNull (3) || String.Compare (r.GetString (0), column.Name, true) != 0) + continue; + + string key = r.GetString (3).ToUpper (); + + ConstraintSchema constraint = null; + if (key.Contains ("PRI")) { + constraint = GetNewPrimaryKeyConstraintSchema ("pk_" + column.Name); + } else if (key.Contains ("UNI")) { + constraint = GetNewUniqueConstraintSchema ("uni_" + column.Name); + } else { + continue; + } + constraint.IsColumnConstraint = true; + constraint.OwnerName = r.GetString (0); +
+ constraints.Add (constraint);
+ } + r.Close ();
+ };
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return constraints; + }
+
+ public override UserSchemaCollection GetUsers ()
+ {
+ UserSchemaCollection users = new UserSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand ("SELECT DISTINCT user from mysql.user where user != '';"); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader ()) {
+ while (r.Read ()) {
+ UserSchema user = new UserSchema (this);
+ user.Name = r.GetString (0);
+
+ users.Add (user);
+ }
+
+ r.Close ();
+ }
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return users;
+ }
+
+ // see:
+ // http://www.htmlite.com/mysql003.php
+ // http://kimbriggs.com/computers/computer-notes/mysql-notes/mysql-data-types.file
+ // http://dev.mysql.com/doc/refman/5.1/en/data-type-overview.html
+ public override DataTypeSchema GetDataType (string name)
+ {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+ + string type = null; + int length = 0; + int scale = 0; + ParseType (name, out type, out length, out scale);
+
+ DataTypeSchema dts = new DataTypeSchema (this);
+ dts.Name = type;
+ switch (type.ToLower ()) {
+ case "tinyint": + case "smallint": + case "mediumint": + case "int": + case "integer": + case "bigint":
+ dts.LengthRange = new Range (length);
+ dts.DataTypeCategory = DataTypeCategory.Integer;
+ break; + case "bit": + dts.LengthRange = new Range (length); //in bits
+ dts.DataTypeCategory = DataTypeCategory.Bit;
+ break; + case "bool": + case "boolean": + dts.LengthRange = new Range (1); //in bits
+ dts.DataTypeCategory = DataTypeCategory.Boolean;
+ break; + case "float": + case "double": + case "double precision": + case "decimal": + case "dec": + dts.LengthRange = new Range (length); + dts.ScaleRange = new Range (scale);
+ dts.DataTypeCategory = DataTypeCategory.Boolean;
+ break; + case "date": + dts.DataTypeCategory = DataTypeCategory.Date;
+ break; + case "datetime": + dts.DataTypeCategory = DataTypeCategory.DateTime;
+ break; + case "timestamp": + dts.DataTypeCategory = DataTypeCategory.TimeStamp;
+ break; + case "time": + dts.DataTypeCategory = DataTypeCategory.Time;
+ break; + case "year": + dts.LengthRange = new Range (length); + dts.DataTypeCategory = DataTypeCategory.Integer;
+ break; + case "binary": + case "char byte": + dts.LengthRange = new Range (length); + dts.DataTypeCategory = DataTypeCategory.Binary;
+ break; + case "varbinary": + dts.LengthRange = new Range (length); + dts.DataTypeCategory = DataTypeCategory.VarBinary;
+ break; + case "tinyblob": + case "mediumblob": + case "longblob": + case "blob": + dts.LengthRange = new Range (length); + dts.DataTypeCategory = DataTypeCategory.Binary;
+ break; + case "tinytext": + case "mediumtext": + case "longtext": + case "text": + dts.LengthRange = new Range (length); + dts.DataTypeCategory = DataTypeCategory.NChar;
+ break; + case "national char": + case "nchar": + dts.LengthRange = new Range (length); + dts.DataTypeCategory = DataTypeCategory.NChar;
+ break; + case "national varchar": + case "nvarchar": + dts.LengthRange = new Range (length); + dts.DataTypeCategory = DataTypeCategory.NVarChar;
+ break; + case "varchar": + dts.LengthRange = new Range (length); + dts.DataTypeCategory = DataTypeCategory.VarChar;
+ break; + case "char": + dts.LengthRange = new Range (length); + dts.DataTypeCategory = DataTypeCategory.Char;
+ break; + case "set": + case "enum": + dts.DataTypeCategory = DataTypeCategory.Integer;
+ break;
+ default:
+ dts = null; + break;
+ }
+
+ return dts;
+ } + + //http://dev.mysql.com/doc/refman/5.1/en/create-database.html + public override void CreateDatabase (DatabaseSchema database) + { + ExecuteNonQuery ("CREATE DATABASE " + database.Name); + } + + //http://dev.mysql.com/doc/refman/5.1/en/create-table.html + public override string GetTableCreateStatement (TableSchema table) + { + StringBuilder sb = new StringBuilder (); + sb.Append ("CREATE TABLE "); + sb.Append (table.Name); + sb.Append (" ("); + + bool first = true; + foreach (ColumnSchema column in table.Columns) { + if (first) + first = false; + else + sb.Append ("," + Environment.NewLine); + + sb.Append (column.Name); + sb.Append (' '); + sb.Append (column.DataType.GetCreateString (column)); + + if (!column.IsNullable) + sb.Append (" NOT NULL"); + if (column.HasDefaultValue) { + sb.Append (" DEFAULT "); + if (column.DefaultValue == null) + sb.Append ("NULL"); + else + sb.Append (column.DefaultValue); + } + //TODO: AUTO_INCREMENT + + foreach (ConstraintSchema constraint in column.Constraints) { + switch (constraint.ConstraintType) { + case ConstraintType.Unique: + sb.Append (" UNIQUE"); + break; + case ConstraintType.PrimaryKey: + sb.Append (" PRIMARY KEY"); + break; + default: + throw new NotImplementedException (); + } + } + + if (column.Comment != null) { + sb.Append (" COMMENT '"); + sb.Append (column.Comment); + sb.Append ("'"); + } + } + //TODO: table comment + + foreach (ConstraintSchema constraint in table.Constraints) { + sb.Append ("," + Environment.NewLine); + sb.Append (GetConstraintString (constraint)); + } + + sb.Append (")"); + + if (table.TableSpaceName != null) { + sb.Append (", TABLESPACE "); + sb.Append (table.TableSpaceName); + sb.Append (" STORAGE DISK"); + } + + sb.Append (";"); + + foreach (TriggerSchema trigger in table.Triggers) { + sb.Append (Environment.NewLine); + sb.Append (GetTriggerCreateStatement (trigger)); + } + + return sb.ToString (); + } + + protected virtual string GetConstraintString (ConstraintSchema constraint) + { + if (constraint.ConstraintType == ConstraintType.Check) + return String.Format ("CHECK ({0})", (constraint as CheckConstraintSchema).Source); + + StringBuilder sb = new StringBuilder (); + sb.Append ("CONSTRAINT "); + sb.Append (constraint.Name); + sb.Append (' '); + + switch (constraint.ConstraintType) { + case ConstraintType.PrimaryKey: + sb.Append ("PRIMARY KEY "); + sb.Append (GetColumnsString (constraint.Columns, true)); + break; + case ConstraintType.Unique: + sb.Append ("UNIQUE "); + sb.Append (GetColumnsString (constraint.Columns, true)); + break; + case ConstraintType.ForeignKey: + sb.Append ("FOREIGN KEY "); + sb.Append (GetColumnsString (constraint.Columns, true)); + sb.Append (" REFERENCES "); + + ForeignKeyConstraintSchema fk = constraint as ForeignKeyConstraintSchema; + sb.Append (fk.ReferenceTable); + sb.Append (' '); + if (fk.ReferenceColumns != null) + sb.Append (GetColumnsString (fk.ReferenceColumns, true)); + break; + default: + throw new NotImplementedException (); + } + + return sb.ToString (); + } + + //http://dev.mysql.com/doc/refman/5.1/en/create-view.html + public override void CreateView (ViewSchema view) + { + ExecuteNonQuery (view.Definition); + } + + //http://dev.mysql.com/doc/refman/5.1/en/create-procedure.html + public override void CreateProcedure (ProcedureSchema procedure) + { + ExecuteNonQuery (procedure.Definition); + } + + //http://dev.mysql.com/doc/refman/5.1/en/create-index.html + public override void CreateIndex (IndexSchema index) + { + throw new NotImplementedException (); + } + + //http://dev.mysql.com/doc/refman/5.1/en/create-trigger.html + public override void CreateTrigger (TriggerSchema trigger) + { + string sql = GetTriggerCreateStatement (trigger); + ExecuteNonQuery (sql); + } + + protected virtual string GetTriggerCreateStatement (TriggerSchema trigger) + { + StringBuilder sb = new StringBuilder (); + + sb.Append ("CREATE TRIGGER "); + sb.Append (trigger.Name); + if (trigger.TriggerType == TriggerType.Before) + sb.Append (" BEFORE "); + else + sb.Append (" AFTER "); + + switch (trigger.TriggerEvent) { + case TriggerEvent.Delete: + sb.Append ("DELETE"); + break; + case TriggerEvent.Insert: + sb.Append ("INSERT"); + break; + case TriggerEvent.Update: + sb.Append ("UPDATE"); + break; + default: + throw new NotImplementedException (); + } + + sb.Append (" ON "); + sb.Append (trigger.TableName); + sb.Append (" FOR EACH ROW "); + sb.Append (Environment.NewLine); + sb.Append (trigger.Source); + sb.Append (";"); + + return sb.ToString (); + } + + //http://dev.mysql.com/doc/refman/5.1/en/create-user.html + public override void CreateUser (UserSchema user) + { + throw new NotImplementedException (); + } + + //http://dev.mysql.com/doc/refman/5.1/en/alter-database.html + public override void AlterDatabase (DatabaseSchema database) + { + throw new NotImplementedException (); + } + + //http://dev.mysql.com/doc/refman/5.1/en/alter-table.html + public override void AlterTable (TableSchema table) + { + throw new NotImplementedException (); + } + + //http://dev.mysql.com/doc/refman/5.1/en/alter-view.html + public override void AlterView (ViewSchema view) + { + ExecuteNonQuery (view.Definition); + } + + //http://dev.mysql.com/doc/refman/5.1/en/alter-procedure.html + public override void AlterProcedure (ProcedureSchema procedure) + { + ExecuteNonQuery (procedure.Definition); + } + + //http://dev.mysql.com/doc/refman/5.1/en/drop-database.html + public override void DropDatabase (DatabaseSchema database) + { + ExecuteNonQuery ("DROP DATABASE IF EXISTS " + database.Name + ";"); + } + + //http://dev.mysql.com/doc/refman/5.1/en/drop-table.html + public override void DropTable (TableSchema table) + { + ExecuteNonQuery ("DROP TABLE IF EXISTS " + table.Name + ";"); + } + + //http://dev.mysql.com/doc/refman/5.1/en/drop-view.html + public override void DropView (ViewSchema view) + { + ExecuteNonQuery ("DROP VIEW IF EXISTS " + view.Name + ";"); + } + + //http://dev.mysql.com/doc/refman/5.1/en/drop-procedure.html + public override void DropProcedure (ProcedureSchema procedure) + {
+ ExecuteNonQuery ("DROP PROCEDURE IF EXISTS " + procedure.Name + ";"); + } + + //http://dev.mysql.com/doc/refman/5.1/en/drop-index.html + public override void DropIndex (IndexSchema index) + { + ExecuteNonQuery ("DROP INDEX " + index.Name + " ON " + index.TableName + ";"); + } + + //http://dev.mysql.com/doc/refman/5.1/en/drop-trigger.html + public override void DropTrigger (TriggerSchema trigger) + { + ExecuteNonQuery ("DROP TRIGGER IF EXISTS " + trigger.Name + ";"); + } + + //http://dev.mysql.com/doc/refman/5.1/en/drop-user.html + public override void DropUser (UserSchema user) + { + ExecuteNonQuery ("DROP USER " + user.Name + ";"); + } + + //http://dev.mysql.com/doc/refman/5.1/en/rename-database.html + public override void RenameDatabase (DatabaseSchema database, string name) + { + ExecuteNonQuery ("RENAME DATABASE " + database.Name + " TO " + name + ";"); + + connectionPool.ConnectionContext.ConnectionSettings.Database = name; + database.Name = name; + } + + //http://dev.mysql.com/doc/refman/5.1/en/rename-table.html + public override void RenameTable (TableSchema table, string name) + { + ExecuteNonQuery ("RENAME TABLE " + table.Name + " TO " + name + ";"); + + table.Name = name; + } + + //http://dev.mysql.com/doc/refman/5.1/en/rename-table.html + public override void RenameView (ViewSchema view, string name) + { + //this is no copy paste error, it really is "RENAME TABLE"
+ ExecuteNonQuery ("RENAME TABLE " + view.Name + " TO " + name + ";"); + + view.Name = name; + } + + //http://dev.mysql.com/doc/refman/5.1/en/rename-user.html + public override void RenameUser (UserSchema user, string name) + { + ExecuteNonQuery ("RENAME USER " + user.Name + " TO " + name + ";"); + + user.Name = name; + } + + public override string GetViewAlterStatement (ViewSchema view) + { + return String.Concat ("DROP VIEW IF EXISTS ", view.Name, "; ", Environment.NewLine, view.Definition); + } + + public override string GetProcedureAlterStatement (ProcedureSchema procedure) + { + return String.Concat ("DROP PROCEDURE IF EXISTS ", procedure.Name, "; ", Environment.NewLine, procedure.Definition); + }
+
+ private int GetMainVersion (IDbCommand command)
+ {
+ string str = (command.Connection as MySqlConnection).ServerVersion;
+ int version = -1;
+ if (int.TryParse (str.Substring (0, str.IndexOf (".")), out version))
+ return version;
+ return -1;
+ } + + private void ParseType (string str, out string type, out int length, out int scale) + { + int parenOpen = str.IndexOf ('('); + int parenClose = str.IndexOf (')'); + int commaPos = -1; + if (parenOpen > 0) + commaPos = str.IndexOf (',', parenOpen); + + if (parenOpen > 0) { + type = str.Substring (0, parenOpen).Trim (); + + string lengthString = null; + if (commaPos > 0) { + lengthString = str.Substring (parenOpen + 1, commaPos - parenOpen - 1); + string scaleString = str.Substring (commaPos + 1, parenClose - commaPos - 1).Trim (); + int.TryParse (scaleString, out scale); + } else { + lengthString = str.Substring (parenOpen + 1, parenClose - parenOpen - 1); + scale = 0; + } + int.TryParse (lengthString, out length); + } else { + type = str; + length = 1; + scale = 0; + } + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/AssemblyInfo.cs.in b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/AssemblyInfo.cs.in new file mode 100644 index 0000000000..ad14e65528 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/AssemblyInfo.cs.in @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("MonoDevelop.Database.Sql.Npgsql")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("http://www.monodevelop.com")] +[assembly: AssemblyCopyright("MIT X11 - Christian Hergert, Ben Motmans")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: AssemblyVersion("@ASSEMBLY_VERSION@")] + +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/ChangeLog b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/ChangeLog new file mode 100644 index 0000000000..a967f012de --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/ChangeLog @@ -0,0 +1,113 @@ +2007-10-29 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Npgsql.addin.xml: Bump MD version. + +2007-10-23 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Npgsql.mdp: Project file names updated by change + in MD path functions. + +2007-10-16 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Npgsql.mdp: Fix required GTK# version. + +2007-09-26 Michael Hutchinson <mhutchinson@novell.com> + + * Makefile.am: Don't deploy .addin.xml file. + * MonoDevelop.Database.Sql.Npgsql.mdp: Don't unnecessarily local-copy + project references. Don't sync EXTRA_DIST with deploy files. Add + Makefile.am to file list. + +2007-09-21 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Npgsql.addin.xml: Bump MD version. + +2007-09-19 Ben Motmans <ben.motmans@gmail.com> + + * MonoDevelop.Database.Sql.Npgsql.addin.xml: temporarily disabled the Create + table command due to a missing feature in the database provider + +2007-09-16 Ben Motmans <ben.motmans@gmail.com> + + * NpgsqlSchemaProvider.cs: IsDBNull check for columns that can have 'null' + values + * Makefile.am: link to the correct Mono.Addins dll + +2007-09-07 Ben Motmans <ben.motmans@gmail.com> + + * NpgsqlSchemaProvider.cs, NpgsqlDbFactory.cs, + MonoDevelop.Database.Sql.Npgsql.addin.xml: improved capabilities system + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am, MonoDevelop.Database.Sql.Npgsql.mdp: use project references + instead of assembly references + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * NpgsqlSchemaProvider.cs: some tweaks in the sql queries + +2007-08-03 Ben Motmans <ben.motmans@gmail.com> + + * NpgsqlConnectionProvider.cs: added support for an error message + * NpgsqlSchemaProvider.cs: added MetaData information and implemented GetProcedureParameters + +2007-08-02 Ben Motmans <ben.motmans@gmail.com> + + * NpgsqlSchemaProvider.cs: CreateTrigger implementation + +2007-08-01 Ben Motmans <ben.motmans@gmail.com> + + * NpgsqlSchemaProvider.cs: Catch exceptions and notify the user + +2007-07-31 Ben Motmans <ben.motmans@gmail.com> + + * NpgsqlDbFactory.cs, NpgsqlGuiProvider.cs: Added a GuiProvider + * NpgsqlSchemaProvider.cs: Implemented CreateTable + +2007-07-25 Ben Motmans <ben.motmans@gmail.com> + + * NpgsqlSchemaProvider.cs, NpgsqlDbFactory.cs: improved metadata support + * NpgsqlPooledDbConnection.cs: expose the GetSchema method of the internal connection + +2007-07-18 Ben Motmans <ben.motmans@gmail.com> + + * NpgsqlSchemaProvider.cs: SupportsSchemaOperation implementation, use of strongly typed + collections, Drop* and Rename* implementations + +2007-07-17 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: initial makefile + * NpgsqlDbFactory.cs: implemented methods required for the connection settings dialog + +2007-07-15 Ben Motmans <ben.motmans@gmail.com> + + * NpgsqlDialect.cs: dialect implementation with keyword detection + * NpgsqlDbFactory.cs: use NpgsqlDialect instead of the obsolete Sql99Dialect + +2007-07-14 Ben Motmans <ben.motmans@gmail.com> + + * NpgsqlConnectionProvider.cs, NpgsqlDbFactory.cs, NpgsqlSchemaProvider.cs: small changes + to reflect API changes + * NpgsqlPooledDbConnection.cs: implementation of ConnectionPool aware connection + +2007-07-10 Ben Motmans <ben.motmans@gmail.com> + + * NpgsqlConnectionProvider.cs: set IsConnectionError property + +2007-07-05 Ben Motmans <ben.motmans@gmail.com> + + * NpgsqlConnectionProvider.cs: ExecuteQueryAsDataSet and ExecuteQueryAsDataTable implementation + * NpgsqlDbFactory.cs: specified the ISqlDialect and added default connection settings + +2007-07-02 Ben Motmans <ben.motmans@gmail.com> + + * NpgsqlSchemaProvider.cs: + Imported the old DbProvider and updated all to code to use the new API + +2007-07-01 Ben Motmans <ben.motmans@gmail.com> + + * NpgsqlSchemaProvider.cs: + * NpgsqlDbFactory.cs: + * NpgsqlConnectionProvider.cs: + Imported original code and splitted in 3 classes diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/Makefile.am b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/Makefile.am new file mode 100644 index 0000000000..6a54d01f5a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/Makefile.am @@ -0,0 +1,47 @@ +ADDIN_BUILD = $(top_builddir)/build/AddIns/MonoDevelop.Database +ASSEMBLY = $(ADDIN_BUILD)/MonoDevelop.Database.Sql.Npgsql.dll +REFS = \ + $(GTK_SHARP_LIBS) \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Components.dll \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Designer.dll \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Sql.dll \ + -r:$(top_builddir)/build/bin/Mono.Addins.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Components.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.Gui.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Ide.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Projects.dll \ + -r:Npgsql \ + -r:System \ + -r:System.Data + +FILES = \ + NpgsqlConnectionProvider.cs \ + NpgsqlDbFactory.cs \ + NpgsqlDialect.cs \ + NpgsqlGuiProvider.cs \ + NpgsqlPooledDbConnection.cs \ + NpgsqlSchemaProvider.cs + +RES = MonoDevelop.Database.Sql.Npgsql.addin.xml + +if ENABLE_POSTGRES +all: $(ASSEMBLY) +else
+all:
+endif + +$(ASSEMBLY): $(FILES) $(build_resources) + mkdir -p $(ADDIN_BUILD) + $(CSC) $(CSC_FLAGS) $(REFS) $(build_resources:%=/resource:%) $(build_sources) -out:$@ -target:library + + +if ENABLE_POSTGRES +assemblydir = $(MD_ADDIN_DIR)/MonoDevelop.Database +assembly_DATA = $(ASSEMBLY) +endif + +CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb +EXTRA_DIST = $(FILES) $(RES) + +include $(top_srcdir)/Makefile.include diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/MonoDevelop.Database.Sql.Npgsql.addin.xml b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/MonoDevelop.Database.Sql.Npgsql.addin.xml new file mode 100644 index 0000000000..c8390662a6 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/MonoDevelop.Database.Sql.Npgsql.addin.xml @@ -0,0 +1,60 @@ +<Addin id = "Database.Sql.Npgsql" + namespace = "MonoDevelop" + name = "Npgsql provider for Mono Data Sql" + author = "Christian Hergert, Ben Motmans" + copyright = "MIT X11" + url = "http://www.monodevelop.com" + description = "Database Module" + version = "0.17.0"> + + <Runtime> + <Import assembly="MonoDevelop.Database.Sql.Npgsql.dll"/> + </Runtime> + + <Dependencies> + <Addin id="Core" version="0.17.0"/> + <Addin id="Core.Gui" version="0.17.0"/> + <Addin id="Ide" version="0.17.0"/> + <Addin id="Database.Sql" version="0.17.0"/> + <Addin id="Database.Components" version="0.17.0"/> + <Addin id="Database.Designer" version="0.17.0"/> + </Dependencies> + + <Extension path = "/MonoDevelop/Database/Sql"> + <DatabaseFactory id = "Npgsql" class = "MonoDevelop.Database.Sql.NpgsqlDbFactory"> + <!-- action flags --> + <Actions category="Database" flags="All" /> + <Actions category="Table" flags="Drop,Rename,Schema" /> <!-- TODO: Create when GetSchema ("DataTypes") is implemented --> + <Actions category="View" flags="All" /> + <Actions category="TableColumn" flags="All" /> + <Actions category="Parameter" flags="Schema" /> + <Actions category="Trigger" flags="All" /> + <Actions category="PrimaryKeyConstraint" flags="Create,Drop,Rename,Schema" /> + <Actions category="ForeignKeyConstraint" flags="Create,Drop,Rename,Schema" /> + <Actions category="CheckConstraint" flags="Create,Drop,Rename,Schema" /> + <Actions category="UniqueConstraint" flags="Create,Drop,Rename,Schema" /> + <Actions category="User" flags="Schema" /> + + <!-- ConnectionSettings capabilities --> + <Capabilities category="ConnectionSettings" action="Schema" flags="Username,Password,Server,Port" /> + <!-- table capabilities --> + <Capabilities category="Table" action="All" flags="Name,Definition,Schema,IsSystem,Columns,Constraints,Trigger" /> + <Capabilities category="Table" action="Alter" flags="AppendConstraint,InsertConstraint,RemoveConstraint,AppendTrigger,InsertTrigger,RemoveTrigger,AppendColumn,InsertColumn,RemoveColumn" /> + <!-- Table Column capabilities --> + <Capabilities category="TableColumn" action="All" flags="Name,Definition,Schema,DataType,DefaultValue,Nullable,Position,Constraints" /> + <Capabilities category="TableColumn" action="Alter" flags="AppendConstraint,InsertConstraint,RemoveConstraint" /> + <!-- View capabilities --> + <Capabilities category="View" action="All" flags="Name,Definition,Schema,Statement,IsSystem" /> + <!-- Trigger capabilities --> + <Capabilities category="Trigger" action="All" flags="Name,Definition,Schema,TableName,TriggerType,TriggerEvent,TriggerFireType,Position,IsActive,Source" /> + <!-- PrimaryKeyConstraint capabilities --> + <Capabilities category="PrimaryKeyConstraint" action="All" flags="Name,Columns,IsColumnConstraint" /> + <!-- ForeignKeyConstraint capabilities --> + <Capabilities category="ForeignKeyConstraint" action="All" flags="Name,Columns,IsColumnConstraint,ReferenceTable,ReferenceColumns,Restrict,Cascade,SetNull,SetDefault,NoAction" /> + <!-- CheckConstraint capabilities --> + <Capabilities category="CheckConstraint" action="All" flags="Name,Columns,IsColumnConstraint,Source" /> + <!-- UniqueConstraint capabilities --> + <Capabilities category="UniqueConstraint" action="All" flags="Name,Columns,IsColumnConstraint" /> + </DatabaseFactory> + </Extension> +</Addin> diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/MonoDevelop.Database.Sql.Npgsql.mdp b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/MonoDevelop.Database.Sql.Npgsql.mdp new file mode 100644 index 0000000000..0c73894c71 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/MonoDevelop.Database.Sql.Npgsql.mdp @@ -0,0 +1,53 @@ +<Project name="MonoDevelop.Database.Sql.Npgsql" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql.Npgsql" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql.Npgsql" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="NpgsqlConnectionProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="NpgsqlSchemaProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="MonoDevelop.Database.Sql.Npgsql.addin.xml" subtype="Code" buildaction="EmbedAsResource" /> + <File name="NpgsqlDbFactory.cs" subtype="Code" buildaction="Compile" /> + <File name="NpgsqlPooledDbConnection.cs" subtype="Code" buildaction="Compile" /> + <File name="NpgsqlDialect.cs" subtype="Code" buildaction="Compile" /> + <File name="NpgsqlGuiProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="Makefile.am" subtype="Code" buildaction="Nothing" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="Npgsql, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" /> + <ProjectReference type="Gac" localcopy="True" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Designer" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Components" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Sql" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core.Gui" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Components" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Ide" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Projects" /> + <ProjectReference type="Project" localcopy="False" refto="Mono.Addins" /> + <ProjectReference type="Gac" localcopy="True" refto="pango-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="atk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + </References> + <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am" BuildTargetName="" CleanTargetName="" SyncReferences="True" IsAutotoolsProject="True" RelativeConfigureInPath="../../../"> + <BuildFilesVar Sync="True" Name="FILES" /> + <DeployFilesVar /> + <ResourcesVar Sync="True" Name="RES" /> + <OthersVar /> + <GacRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <AsmRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <ProjectRefVar Sync="True" Name="REFS" Prefix="-r:" /> + </MonoDevelop.Autotools.MakefileInfo> +</Project>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlConnectionProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlConnectionProvider.cs new file mode 100644 index 0000000000..2d02166a3b --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlConnectionProvider.cs @@ -0,0 +1,59 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using Npgsql;
+using System.Collections.Generic;
+
namespace MonoDevelop.Database.Sql
+{
+ public class NpgsqlConnectionProvider : AbstractConnectionProvider
+ { + public override IPooledDbConnection CreateConnection (IConnectionPool pool, DatabaseConnectionSettings settings, out string error)
+ { + string connStr = null;
+ try {
+ if (settings.UseConnectionString) { + connStr = settings.ConnectionString;
+ } else { + //User ID=root;Password=myPassword;Host=localhost;Port=5432;Database=myDataBase;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0; + connStr = String.Format ("User ID={0};Password={1};Host={2};Port={3};Database={4};", + settings.Username, settings.Password, settings.Server, settings.Port, settings.Database);
+ } + connStr = SetConnectionStringParameter (connStr, String.Empty, "Pooling", "false");
+ NpgsqlConnection connection = new NpgsqlConnection (connStr);
+ connection.Open ();
+ + error = null;
+ return new NpgsqlPooledDbConnection (pool, connection);
+ } catch (Exception e) { + error = e.Message;
+ return null;
+ }
+ }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlDbFactory.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlDbFactory.cs new file mode 100644 index 0000000000..95c119c50e --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlDbFactory.cs @@ -0,0 +1,94 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+ +using System;
+using System.Data;
+using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Database.Components;
+
namespace MonoDevelop.Database.Sql
+{
+ public class NpgsqlDbFactory : AbstractDbFactory
+ { + private ISqlDialect dialect; + private IConnectionProvider connectionProvider; + private IGuiProvider guiProvider; + + public override string Identifier { + get { return "Npgsql"; } + } +
+ public override string Name { + get { return "PostgreSQL database"; } + } + + public override ISqlDialect Dialect { + get { + if (dialect == null) + dialect = new NpgsqlDialect (); + return dialect; + } + } + + public override IConnectionProvider ConnectionProvider { + get { + if (connectionProvider == null) + connectionProvider = new NpgsqlConnectionProvider (); + return connectionProvider; + } + } + + public override IGuiProvider GuiProvider { + get { + if (guiProvider == null) + guiProvider = new NpgsqlGuiProvider (); + return guiProvider; + } + } + + public override IConnectionPool CreateConnectionPool (DatabaseConnectionContext context) + { + return new DefaultConnectionPool (this, ConnectionProvider, context); + } + + public override ISchemaProvider CreateSchemaProvider (IConnectionPool connectionPool) + { + return new NpgsqlSchemaProvider (connectionPool); + } + + public override DatabaseConnectionSettings GetDefaultConnectionSettings () + { + DatabaseConnectionSettings settings = new DatabaseConnectionSettings (); + settings.ProviderIdentifier = Identifier; + settings.Server = "localhost"; + settings.Port = 5432; + settings.Username = "postgres"; + settings.MaxPoolSize = 5; + + return settings; + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlDialect.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlDialect.cs new file mode 100644 index 0000000000..a35c0c1c61 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlDialect.cs @@ -0,0 +1,451 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic; +
namespace MonoDevelop.Database.Sql
+{
+ public class NpgsqlDialect : AbstractSqlDialect
+ { + public override string QuoteIdentifier (string identifier) + { + if (identifier == null) + throw new ArgumentNullException ("identifier"); + + if (IsReservedWord (identifier) || identifier.Contains (" ")) + return String.Concat ('"', identifier, '"'); + + return identifier; + } + + public override string MarkAsParameter (string identifier) + { + if (identifier == null) + throw new ArgumentNullException ("identifier"); + + return ":" + identifier; + } + + //http://www.postgresql.org/docs/8.1/interactive/sql-keywords-appendix.html + protected virtual bool IsReservedWord (string word) + { + word = word.ToUpper (); + + switch (word) { + case "A": + case "ABS": + case "ADA": + case "ALIAS": + case "ALL": + case "ALLOCATE": + case "ALWAYS": + case "ANALYSE": + case "ANALYZE": + case "AND": + case "ANY": + case "ARE": + case "ARRAY": + case "AS": + case "ASC": + case "ASENSITIVE": + case "ASYMMETRIC": + case "ATOMIC": + case "ATTRIBUTE": + case "ATTRIBUTES": + case "AUTHORIZATION": + case "AVG": + case "BERNOULLI": + case "BETWEEN": + case "BINARY": + case "BITVAR": + case "BIT_LENGTH": + case "BLOB": + case "BOTH": + case "BREADTH": + case "C": + case "CALL": + case "CARDINALITY": + case "CASCADED": + case "CASE": + case "CAST": + case "CATALOG": + case "CATALOG_NAME": + case "CEIL": + case "CEILING": + case "CHARACTERS": + case "CHARACTER_LENGTH": + case "CHARACTER_SET_CATALOG": + case "CHARACTER_SET_NAME": + case "CHARACTER_SET_SCHEMA": + case "CHAR_LENGTH": + case "CHECK": + case "CHECKED": + case "CLASS_ORIGIN": + case "CLOB": + case "COBOL": + case "COLLATE": + case "COLLATION": + case "COLLATION_CATALOG": + case "COLLATION_NAME": + case "COLLATION_SCHEMA": + case "COLLECT": + case "COLUMN": + case "COLUMN_NAME": + case "COMMAND_FUNCTION": + case "COMMAND_FUNCTION_CODE": + case "COMPLETION": + case "CONDITION": + case "CONDITION_NUMBER": + case "CONNECT": + case "CONNECTION_NAME": + case "CONSTRAINT": + case "CONSTRAINT_CATALOG": + case "CONSTRAINT_NAME": + case "CONSTRAINT_SCHEMA": + case "CONSTRUCTOR": + case "CONTAINS": + case "CONTINUE": + case "CORR": + case "CORRESPONDING": + case "COUNT": + case "COVAR_POP": + case "COVAR_SAMP": + case "CREATE": + case "CROSS": + case "CUBE": + case "CUME_DIST": + case "CURRENT": + case "CURRENT_DATE": + case "CURRENT_DEFAULT_TRANSFORM_GROUP": + case "CURRENT_PATH": + case "CURRENT_ROLE": + case "CURRENT_TIME": + case "CURRENT_TIMESTAMP": + case "CURRENT_TRANSFORM_GROUP_FOR_TYPE": + case "CURRENT_USER": + case "CURSOR_NAME": + case "DATA": + case "DATE": + case "DATETIME_INTERVAL_CODE": + case "DATETIME_INTERVAL_PRECISION": + case "DEFAULT": + case "DEFERRABLE": + case "DEFINED": + case "DEGREE": + case "DENSE_RANK": + case "DEPTH": + case "DEREF": + case "DERIVED": + case "DESC": + case "DESCRIBE": + case "DESCRIPTOR": + case "DESTROY": + case "DESTRUCTOR": + case "DETERMINISTIC": + case "DIAGNOSTICS": + case "DICTIONARY": + case "DISCONNECT": + case "DISPATCH": + case "DISTINCT": + case "DO": + case "DYNAMIC": + case "DYNAMIC_FUNCTION": + case "DYNAMIC_FUNCTION_CODE": + case "ELEMENT": + case "ELSE": + case "END": + case "END-EXEC": + case "EQUALS": + case "EVERY": + case "EXCEPT": + case "EXCEPTION": + case "EXCLUDE": + case "EXEC": + case "EXISTING": + case "EXP": + case "0": + case "FILTER": + case "FINAL": + case "FLOOR": + case "FOLLOWING": + case "FOR": + case "FOREIGN": + case "FORTRAN": + case "FOUND": + case "FREE": + case "FREEZE": + case "FROM": + case "FULL": + case "FUSION": + case "G": + case "GENERAL": + case "GENERATED": + case "GET": + case "GO": + case "GOTO": + case "GRANT": + case "GROUP": + case "GROUPING": + case "HAVING": + case "HIERARCHY": + case "HOST": + case "IDENTITY": + case "IGNORE": + case "ILIKE": + case "IMPLEMENTATION": + case "IN": + case "INDICATOR": + case "INFIX": + case "INITIALIZE": + case "INITIALLY": + case "INNER": + case "INSTANCE": + case "INSTANTIABLE": + case "INTERSECT": + case "INTERSECTION": + case "INTO": + case "IS": + case "ISNULL": + case "ITERATE": + case "JOIN": + case "K": + case "KEY_MEMBER": + case "KEY_TYPE": + case "LATERAL": + case "LEADING": + case "LEFT": + case "LENGTH": + case "LESS": + case "LIKE": + case "LIMIT": + case "LN": + case "LOCALTIME": + case "LOCALTIMESTAMP": + case "LOCATOR": + case "LOWER": + case "M": + case "MAP": + case "MATCHED": + case "MAX": + case "MEMBER": + case "MERGE": + case "MESSAGE_LENGTH": + case "MESSAGE_OCTET_LENGTH": + case "MESSAGE_TEXT": + case "METHOD": + case "MIN": + case "MOD": + case "MODIFIES": + case "MODIFY": + case "MODULE": + case "MORE": + case "MULTISET": + case "MUMPS": + case "NAME": + case "NATURAL": + case "NCLOB": + case "NESTING": + case "NEW": + case "NOLOGIN": + case "NORMALIZE": + case "NORMALIZED": + case "NOT": + case "NOTNULL": + case "NULL": + case "NULLABLE": + case "NULLS": + case "NUMBER": + case "OCTETS": + case "OCTET_LENGTH": + case "OFF": + case "OFFSET": + case "OLD": + case "ON": + case "ONLY": + case "OPEN": + case "OPERATION": + case "OPTIONS": + case "OR": + case "ORDER": + case "ORDERING": + case "ORDINALITY": + case "OTHERS": + case "OUTER": + case "OUTPUT": + case "OVER": + case "OVERLAPS": + case "OVERRIDING": + case "PAD": + case "PARAMETER": + case "PARAMETERS": + case "PARAMETER_MODE": + case "PARAMETER_NAME": + case "PARAMETER_ORDINAL_POSITION": + case "PARAMETER_SPECIFIC_CATALOG": + case "PARAMETER_SPECIFIC_NAME": + case "PARAMETER_SPECIFIC_SCHEMA": + case "PARTITION": + case "PASCAL": + case "PATH": + case "PERCENTILE_CONT": + case "PERCENTILE_DISC": + case "PERCENT_RANK": + case "PLACING": + case "PLI": + case "POSTFIX": + case "POWER": + case "PRECEDING": + case "PREFIX": + case "PREORDER": + case "PRIMARY": + case "PUBLIC": + case "RANGE": + case "RANK": + case "READS": + case "RECURSIVE": + case "REF": + case "REFERENCES": + case "REFERENCING": + case "REGR_AVGX": + case "REGR_AVGY": + case "REGR_COUNT": + case "REGR_INTERCEPT": + case "REGR_R2": + case "REGR_SLOPE": + case "REGR_SXX": + case "REGR_SXY": + case "REGR_SYY": + case "RESULT": + case "RETURN": + case "RETURNED_CARDINALITY": + case "RETURNED_LENGTH": + case "RETURNED_OCTET_LENGTH": + case "RETURNED_SQLSTATE": + case "RIGHT": + case "ROLLUP": + case "ROUTINE": + case "ROUTINE_CATALOG": + case "ROUTINE_NAME": + case "ROUTINE_SCHEMA": + case "ROW_COUNT": + case "ROW_NUMBER": + case "SCALE": + case "SCHEMA_NAME": + case "SCOPE": + case "SCOPE_CATALOG": + case "SCOPE_NAME": + case "SCOPE_SCHEMA": + case "SEARCH": + case "SECTION": + case "SELECT": + case "SELF": + case "SENSITIVE": + case "SERVER_NAME": + case "SESSION_USER": + case "SETS": + case "SIMILAR": + case "SIZE": + case "SOME": + case "SOURCE": + case "SPACE": + case "SPECIFIC": + case "SPECIFICTYPE": + case "SPECIFIC_NAME": + case "SQL": + case "SQLCODE": + case "SQLERROR": + case "SQLEXCEPTION": + case "SQLSTATE": + case "SQLWARNING": + case "SQRT": + case "STATE": + case "STATIC": + case "STDDEV_POP": + case "STDDEV_SAMP": + case "STRUCTURE": + case "STYLE": + case "SUBCLASS_ORIGIN": + case "SUBLIST": + case "SUBMULTISET": + case "SUM": + case "SYMMETRIC": + case "SYSTEM_USER": + case "TABLE": + case "TABLESAMPLE": + case "TABLE_NAME": + case "TERMINATE": + case "THAN": + case "THEN": + case "TIES": + case "TIMEZONE_HOUR": + case "TIMEZONE_MINUTE": + case "TO": + case "TOP_LEVEL_COUNT": + case "TRAILING": + case "TRANSACTIONS_COMMITTED": + case "TRANSACTIONS_ROLLED_BACK": + case "TRANSACTION_ACTIVE": + case "TRANSFORM": + case "TRANSFORMS": + case "TRANSLATE": + case "TRANSLATION": + case "TRIGGER_CATALOG": + case "TRIGGER_NAME": + case "TRIGGER_SCHEMA": + case "1": + case "UESCAPE": + case "UNBOUNDED": + case "UNDER": + case "UNION": + case "UNIQUE": + case "UNNAMED": + case "UNNEST": + case "UPPER": + case "USAGE": + case "USER": + case "USER_DEFINED_TYPE_CATALOG": + case "USER_DEFINED_TYPE_CODE": + case "USER_DEFINED_TYPE_NAME": + case "USER_DEFINED_TYPE_SCHEMA": + case "USING": + case "VALUE": + case "VARIABLE": + case "VAR_POP": + case "VAR_SAMP": + case "VERBOSE": + case "WHEN": + case "WHENEVER": + case "WHERE": + case "WIDTH_BUCKET": + case "WINDOW": + case "WITHIN": + return true; + default: + return false; + } + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlGuiProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlGuiProvider.cs new file mode 100644 index 0000000000..d568ac6c06 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlGuiProvider.cs @@ -0,0 +1,74 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using Gtk; +using System;
+using System.Data;
+using System.Collections.Generic; +using MonoDevelop.Database.Designer; +using MonoDevelop.Database.Components;
+
namespace MonoDevelop.Database.Sql
+{
+ public class NpgsqlGuiProvider : IGuiProvider
+ { + public bool ShowSelectDatabaseDialog (bool create, out string database) + { + database = null; + return false; + } + + public bool ShowTableEditorDialog (ISchemaProvider schemaProvider, TableSchema table, bool create) + { + return RunDialog (new TableEditorDialog (schemaProvider, table, create)); + } + + public bool ShowViewEditorDialog (ISchemaProvider schemaProvider, ViewSchema view, bool create) + { + return RunDialog (new ViewEditorDialog (schemaProvider, view, create)); + } + + public bool ShowProcedureEditorDialog (ISchemaProvider schemaProvider, ProcedureSchema procedure, bool create) + { + return RunDialog (new ProcedureEditorDialog (schemaProvider, procedure, create)); + } + + public bool ShowUserEditorDialog (ISchemaProvider schemaProvider, UserSchema user, bool create) + { + return RunDialog (new UserEditorDialog (schemaProvider, user, create)); + } + + private bool RunDialog (Dialog dlg) + { + bool result = false; + try { + if (dlg.Run () == (int)ResponseType.Ok) + result = true; + } finally { + dlg.Destroy (); + } + return result; + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlPooledDbConnection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlPooledDbConnection.cs new file mode 100644 index 0000000000..8851e47b1a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlPooledDbConnection.cs @@ -0,0 +1,81 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic; +using Npgsql;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class NpgsqlPooledDbConnection : AbstractPooledDbConnection
+ { + public NpgsqlPooledDbConnection (IConnectionPool connectionPool, IDbConnection connection) + : base (connectionPool, connection) + { + } + + public override DataSet ExecuteSet (IDbCommand command) + { + if (command == null) + throw new ArgumentException ("command"); + + DataSet set = new DataSet (); + using (command) { + using (NpgsqlDataAdapter adapter = new NpgsqlDataAdapter (command as NpgsqlCommand)) { + try { + adapter.Fill (set); + } catch (Exception e) { + QueryService.RaiseException (e); + } + } + } + return set; + } + + public override DataTable ExecuteTable (IDbCommand command) + { + if (command == null) + throw new ArgumentException ("command"); + + DataTable table = new DataTable (); + using (command) { + using (NpgsqlDataAdapter adapter = new NpgsqlDataAdapter (command as NpgsqlCommand)) { + try { + adapter.Fill (table); + } catch (Exception e) { + QueryService.RaiseException (e); + } + } + } + return table; + } + + public override DataTable GetSchema (string collectionName, params string[] restrictionValues) + { + return (connection as NpgsqlConnection).GetSchema (collectionName, restrictionValues); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlSchemaProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlSchemaProvider.cs new file mode 100644 index 0000000000..3a37b774cc --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Npgsql/NpgsqlSchemaProvider.cs @@ -0,0 +1,831 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections.Generic;
+using Npgsql; +using MonoDevelop.Core;
+
namespace MonoDevelop.Database.Sql
+{ + public class NpgsqlSchemaProvider : AbstractSchemaProvider
+ {
+ public NpgsqlSchemaProvider (IConnectionPool connectionPool)
+ : base (connectionPool)
+ {
+ }
+
+ public override TableSchemaCollection GetTables ()
+ {
+ TableSchemaCollection tables = new TableSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand ( + "SELECT DISTINCT c.relname, n.nspname, u.usename " + + "FROM pg_class c, pg_namespace n, pg_user u " + + "WHERE c.relnamespace = n.oid " + + "AND c.relowner = u.usesysid " + + "AND c.relkind='r' AND NOT EXISTS " + + " (SELECT 1 FROM pg_rewrite r " + + " WHERE r.ev_class = c.oid AND r.ev_type = '1') " + + "ORDER BY relname;" + ); + + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ TableSchema table = new TableSchema (this);
+
+ table.Name = r.GetString (0); + table.IsSystemTable = table.Name.StartsWith ("pg_") || table.Name.StartsWith ("sql_"); + table.SchemaName = r.GetString (1); + table.OwnerName = r.GetString (2); + +// StringBuilder sb = new StringBuilder(); +// sb.AppendFormat ("-- Table: {0}\n", table.Name); +// sb.AppendFormat ("-- DROP TABLE {0};\n\n", table.Name); +// sb.AppendFormat ("CREATE TABLE {0} (\n", table.Name); +// +// ColumnSchema[] columns = table.Columns; +// string[] parts = new string[columns.Length]; +// for (int i = 0; i < parts.Length; i++) { +// parts[i] = "\t" + columns[i].Definition; +// } +// sb.Append (String.Join (",\n", parts)); +// +// ConstraintSchema[] cons = table.Constraints; +// parts = new string[cons.Length]; +// if (cons.Length > 0) +// sb.Append (",\n"); +// for (int i = 0; i < parts.Length; i++) { +// parts[i] = "\t" + cons[i].Definition; +// } +// sb.Append (String.Join (",\n", parts)); +// +// sb.Append ("\n);\n"); +// sb.AppendFormat ("COMMENT ON TABLE {0} IS '{1}';", table.Name, table.Comment); +// table.Definition = sb.ToString();
+
+ tables.Add (table);
+ } + r.Close ();
+ }
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return tables;
+ }
+
+ public override ColumnSchemaCollection GetTableColumns (TableSchema table)
+ {
+ ColumnSchemaCollection columns = new ColumnSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand ( + "SELECT a.attname, a.attnotnull, a.attlen, " + + "typ.typname, adef.adsrc " + + "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, " + + " pg_catalog.pg_type typ " + + "WHERE " + + " a.attrelid = (SELECT oid FROM pg_catalog.pg_class " + + " WHERE relname='" + table.Name + "') " + + "AND a.attnum > 0 AND NOT a.attisdropped " + + "AND a.atttypid = typ.oid " + + "ORDER BY a.attnum;" + ); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ColumnSchema column = new ColumnSchema (this, table);
+
+ column.Name = r.GetString (0);
+ column.DataTypeName = r.GetString (3);
+ column.IsNullable = r.GetBoolean (1);
+ column.DefaultValue = r.IsDBNull (4) ? null : r.GetString (4); + column.DataType.LengthRange.Default = r.GetInt32 (2); + +// StringBuilder sb = new StringBuilder(); +// sb.AppendFormat("{0} {1}{2}", +// column.Name, +// column.DataTypeName, +// (column.DataType.LengthRange.Default > 0) ? ("(" + column.DataType.LengthRange.Default + ")") : ""); +// sb.AppendFormat(" {0}", column.IsNullable ? "NULL" : "NOT NULL"); +// if (column.DefaultValue.Length > 0) +// sb.AppendFormat(" DEFAULT {0}", column.DefaultValue); +// column.Definition = sb.ToString();
+
+ columns.Add (column);
+ } + r.Close ();
+ };
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return columns;
+ }
+
+ public override ViewSchemaCollection GetViews ()
+ {
+ ViewSchemaCollection views = new ViewSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand (
+ "SELECT v.schemaname, v.viewname, v.viewowner, v.definition," + + " (c.oid <= " + LastSystemOID + "), " + + "(SELECT description from pg_description pd, " + + " pg_class pc WHERE pc.oid=pd.objoid AND pc.relname=" + + " v.viewname) " + + "FROM pg_views v, pg_class c " + + "WHERE v.viewname = c.relname " + + "ORDER BY viewname"
+ ); +
+ try { + using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ViewSchema view = new ViewSchema (this);
+
+ view.Name = r.GetString (1);
+ view.OwnerName = r.GetString (2); + view.SchemaName = r.GetString (0); + view.IsSystemView = r.GetBoolean (4); + view.Comment = r.IsDBNull (5) ? null : r.GetString (5); + +// StringBuilder sb = new StringBuilder(); +// sb.AppendFormat ("-- View: {0}\n", view.Name); +// sb.AppendFormat ("-- DROP VIEW {0};\n\n", view.Name); +// sb.AppendFormat ("CREATE VIEW {0} AS (\n", view.Name); +// string core = r.GetString(3); +// sb.AppendFormat (" {0}\n);", core.Substring (0, core.Length-1)); +// view.Definition = sb.ToString (); +
+ views.Add (view);
+ } + r.Close ();
+ }
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release (); +
+ return views;
+ }
+
+ public override ColumnSchemaCollection GetViewColumns (ViewSchema view)
+ {
+ ColumnSchemaCollection columns = new ColumnSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand ( + "SELECT attname, typname, attlen, attnotnull " + + "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='" + + view.Name + "') " + + " AND a.attnum > 0 AND NOT a.attisdropped " + + " ORDER BY a.attnum;" + ); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ColumnSchema column = new ColumnSchema (this, view);
+ + column.Name = r.GetString(0); + column.DataTypeName = r.GetString (1); + column.SchemaName = view.SchemaName; + column.IsNullable = r.GetBoolean (3); + column.DataType.LengthRange.Default = r.GetInt32 (2);
+
+ columns.Add (column);
+ } + r.Close ();
+ };
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return columns;
+ }
+
+ public override ProcedureSchemaCollection GetProcedures ()
+ {
+ ProcedureSchemaCollection procedures = new ProcedureSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand (
+ "SELECT pc.proname, pc.oid::integer, pl.lanname, pc.prosrc " + + "FROM " + + " pg_proc pc, " + + " pg_user pu, " + + " pg_type pt, " + + " pg_language pl " + + "WHERE pc.proowner = pu.usesysid " + + "AND pc.prorettype = pt.oid " + + "AND pc.prolang = pl.oid " + + "UNION " + + "SELECT pc.proname, pt.oid::integer, pl.lanname, pc.prosrc " + + "FROM " + + " pg_proc pc, " + + " pg_user pu, " + + " pg_type pt, " + + " pg_language pl " + + "WHERE pc.proowner = pu.usesysid " + + "AND pc.prorettype = 0 " + + "AND pc.prolang = pl.oid;"
+ );
+ try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ProcedureSchema procedure = new ProcedureSchema (this); + + procedure.Name = r.GetString (0); + procedure.Definition = r.GetString (3); + procedure.LanguageName = r.GetString (2); + + if (!r.IsDBNull (1) && r.GetInt32 (1) <= LastSystemOID) + procedure.IsSystemProcedure = true;
+
+ procedures.Add (procedure);
+ } + r.Close ();
+ }
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return procedures;
+ }
+
+ public override ParameterSchemaCollection GetProcedureParameters (ProcedureSchema procedure)
+ {
+ ParameterSchemaCollection parameters = new ParameterSchemaCollection (); + + // FIXME: Won't work properly with overload functions. + // Maybe check the number of columns in the parameters for + // proper match. + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand (String.Format ( + "SELECT format_type (prorettype, NULL) " + + "FROM pg_proc pc, pg_language pl " + + "WHERE pc.prolang = pl.oid " + + "AND pc.proname = '{0}';", procedure.Name
+ ));
+ try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) { + ParameterSchema param = new ParameterSchema (this); + + param.DataTypeName = r.GetString (0); + param.Name = r.GetString (0); + parameters.Add (param);
+ } + r.Close ();
+ }
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return parameters;
+ }
+
+ public override ConstraintSchemaCollection GetTableConstraints (TableSchema table)
+ {
+ ConstraintSchemaCollection constraints = new ConstraintSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand (String.Format ( + "SELECT " + + "pc.conname, " + + "pg_catalog.pg_get_constraintdef(pc.oid, true) AS consrc, " + + "pc.contype, " + + "CASE WHEN pc.contype='u' OR pc.contype='p' THEN ( " + + " SELECT " + + " indisclustered " + + " FROM " + + " pg_catalog.pg_depend pd, " + + " pg_catalog.pg_class pl, " + + " pg_catalog.pg_index pi " + + " WHERE " + + " pd.refclassid=pc.tableoid " + + " AND pd.refobjid=pc.oid " + + " AND pd.objid=pl.oid " + + " AND pl.oid=pi.indexrelid " + + ") ELSE " + + " NULL " + + "END AS indisclustered " + + "FROM " + + "pg_catalog.pg_constraint pc " + + "WHERE " + + "pc.conrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname='{0}' " + + " AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace " + + " WHERE nspname='{1}')) " + + "ORDER BY " + + "1;", table.Name, table.SchemaName + )); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) { + while (r.Read ()) { + ConstraintSchema constraint = null; + + //TODO: Add support for Check constraints. + switch (r.GetString (2)) { + case "f": + string match = @".*REFERENCES (.+)\(.*\).*"; + constraint = new ForeignKeyConstraintSchema (this); + if (Regex.IsMatch (r.GetString (1), match)) + (constraint as ForeignKeyConstraintSchema).ReferenceTableName + = Regex.Match (r.GetString (1), match).Groups[0].Captures[0].Value; + break; + case "u": + constraint = new UniqueConstraintSchema (this); + break; + case "p": + default: + constraint = new PrimaryKeyConstraintSchema (this); + break; + } + + constraint.Name = r.GetString (0); + constraint.Definition = r.GetString (1); + + int parenOpen = constraint.Definition.IndexOf ('('); + if (parenOpen > 0) { + int parenClose = constraint.Definition.IndexOf (')'); + string colstr = constraint.Definition.Substring (parenOpen + 1, parenClose - parenOpen - 1); + foreach (string col in colstr.Split (',')) { + ColumnSchema column = new ColumnSchema (this, table); + column.Name = col.Trim (); + constraint.Columns.Add (column); + } + } + + constraints.Add (constraint); + } + r.Close ();
+ }
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return constraints;
+ }
+
+ public override UserSchemaCollection GetUsers ()
+ {
+ UserSchemaCollection users = new UserSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand ("SELECT * FROM pg_user;"); +
+ try { + using (command) {
+ using (IDataReader r = command.ExecuteReader ()) {
+ while (r.Read ()) {
+ UserSchema user = new UserSchema (this);
+ + user.Name = r.GetString (0); + user.UserId = String.Format ("{0}", r.GetValue (1)); + user.Expires = r.IsDBNull (6) ? DateTime.MinValue : r.GetDateTime (6); + //user.Options["createdb"] = r.GetBoolean (2); + //user.Options["createuser"] = r.GetBoolean (3); + user.Password = r.GetString (5); + + StringBuilder sb = new StringBuilder (); + sb.AppendFormat ("-- User: \"{0}\"\n\n", user.Name); + sb.AppendFormat ("-- DROP USER {0};\n\n", user.Name); + sb.AppendFormat ("CREATE USER {0}", user.Name); + sb.AppendFormat (" WITH SYSID {0}", user.UserId); + if (user.Password != "********") + sb.AppendFormat (" ENCRYPTED PASSWORD {0}", user.Password); + //sb.AppendFormat (((bool) user.Options["createdb"]) ? + // " CREATEDB" : " NOCREATEDB"); + //sb.AppendFormat (((bool) user.Options["createuser"]) ? + // " CREATEUSER" : " NOCREATEUSER"); + if (user.Expires != DateTime.MinValue) + sb.AppendFormat (" VALID UNTIL {0}", user.Expires); + sb.Append (";"); + user.Definition = sb.ToString (); +
+ users.Add (user);
+ }
+ r.Close ();
+ }
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return users;
+ }
+
+// public override DataTypeSchema GetDataType (string name)
+// {
+// if (name == null)
+// throw new ArgumentNullException ("name");
+// name = name.ToUpper ();
+//
+// DataTypeSchema dts = new DataTypeSchema (this);
+// dts.Name = name;
+// switch (name) {
+// //TODO: IMPLEMENT
+// case "":
+// break;
+// default:
+// dts = null; +// break;
+// }
+//
+// return dts;
+// } + + //http://www.postgresql.org/docs/8.2/interactive/sql-createdatabase.html + public override void CreateDatabase (DatabaseSchema database) + {
+ ExecuteNonQuery ("CREATE DATABASE " + database.Name); + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-createtable.html + public override string GetTableCreateStatement (TableSchema table) + { + StringBuilder sb = new StringBuilder (); + + sb.Append ("CREATE TABLE "); + sb.Append (table.Name); + sb.Append (" ("); + + bool first = true; + foreach (ColumnSchema column in table.Columns) { + if (first) + first = false; + else + sb.Append ("," + Environment.NewLine); + + sb.Append (column.Name); + sb.Append (' '); + sb.Append (column.DataType.GetCreateString (column)); + + if (!column.IsNullable) + sb.Append (" NOT NULL"); + + if (column.HasDefaultValue) { + sb.Append (" DEFAULT "); + if (column.DefaultValue == null) + sb.Append ("NULL"); + else + sb.Append (column.DefaultValue); + } + + foreach (ConstraintSchema constraint in column.Constraints) + sb.Append (GetConstraintString (constraint, false)); + } + + foreach (ConstraintSchema constraint in table.Constraints) { + sb.Append ("," + Environment.NewLine); + sb.Append (GetConstraintString (constraint, true)); + } + + sb.Append (")"); + + if (table.TableSpaceName != null) { + sb.Append (" TABLESPACE "); + sb.Append (table.TableSpaceName); + sb.Append (';'); + } + + foreach (TriggerSchema trigger in table.Triggers) { + sb.Append (Environment.NewLine); + sb.Append (GetTriggerCreateStatement (trigger)); + } + + return sb.ToString (); + } + + protected virtual string GetConstraintString (ConstraintSchema constraint, bool isTableConstraint) + { + StringBuilder sb = new StringBuilder (); + sb.Append ("CONSTRAINT "); + sb.Append (constraint.Name); + sb.Append (' '); + + switch (constraint.ConstraintType) { + case ConstraintType.PrimaryKey: + sb.Append ("PRIMARY KEY "); + if (isTableConstraint) + sb.Append (GetColumnsString (constraint.Columns, true)); + break; + case ConstraintType.Unique: + sb.Append ("UNIQUE "); + if (isTableConstraint) + sb.Append (GetColumnsString (constraint.Columns, true)); + break; + case ConstraintType.ForeignKey: + sb.Append ("FOREIGN KEY "); + sb.Append (GetColumnsString (constraint.Columns, true)); + sb.Append (" REFERENCES "); + + ForeignKeyConstraintSchema fk = constraint as ForeignKeyConstraintSchema; + sb.Append (fk.ReferenceTable); + sb.Append (' '); + if (fk.ReferenceColumns != null) + sb.Append (GetColumnsString (fk.ReferenceColumns, true)); + break; + case ConstraintType.Check: + sb.Append ("CHECK ("); + sb.Append ((constraint as CheckConstraintSchema).Source); + sb.Append (")"); + break; + default: + throw new NotImplementedException (); + } + + return sb.ToString (); + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-createview.html + public override void CreateView (ViewSchema view) + { + throw new NotImplementedException (); + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-createindex.html + //http://www.postgresql.org/docs/8.2/interactive/sql-createconstraint.html + public override void CreateIndex (IndexSchema index) + { + throw new NotImplementedException (); + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-createtrigger.html + public override void CreateTrigger (TriggerSchema trigger) + { + string sql = GetTriggerCreateStatement (trigger); + ExecuteNonQuery (sql); + } + + protected virtual string GetTriggerCreateStatement (TriggerSchema trigger) + { + StringBuilder sb = new StringBuilder (); + + sb.Append ("CREATE TRIGGER "); + sb.Append (trigger.Name); + + switch (trigger.TriggerType) { + case TriggerType.Before: + sb.Append (" BEFORE"); + break; + case TriggerType.After: + sb.Append (" AFTER"); + break; + default: + throw new NotImplementedException (); + } + + switch (trigger.TriggerEvent) { + case TriggerEvent.Insert: + sb.Append (" INSERT "); + break; + case TriggerEvent.Update: + sb.Append (" UPDATE "); + break; + case TriggerEvent.Delete: + sb.Append (" DELETE "); + break; + default: + throw new NotImplementedException (); + } + + sb.Append ("ON "); + sb.Append (trigger.TableName); + sb.Append (' '); + sb.Append (Environment.NewLine); + + switch (trigger.TriggerFireType) { + case TriggerFireType.ForEachRow: + sb.Append (" FOR EACH ROW "); + break; + case TriggerFireType.ForEachStatement: + sb.Append (" FOR EACH STATEMENT "); + break; + default: + throw new NotImplementedException (); + } + + sb.Append (Environment.NewLine); + sb.Append ("EXECUTE PROCEDURE "); + sb.Append (trigger.Source); + sb.Append (";"); + + return sb.ToString (); + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-createuser.html + public override void CreateUser (UserSchema user) + { + throw new NotImplementedException (); + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-alterdatabase.html + public override void AlterDatabase (DatabaseSchema database) + { + throw new NotImplementedException (); + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-altertable.html + public override void AlterTable (TableSchema table) + { + throw new NotImplementedException (); + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-alterindex.html + public override void AlterIndex (IndexSchema index) + { + throw new NotImplementedException (); + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-altertrigger.html + public override void AlterTrigger (TriggerSchema trigger) + { + throw new NotImplementedException (); + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-alteruser.html + public override void AlterUser (UserSchema user) + { + throw new NotImplementedException (); + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-dropdatabase.html + public override void DropDatabase (DatabaseSchema database) + { + ExecuteNonQuery ("DROP DATABASE IF EXISTS " + database.Name + ";"); + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-droptable.html + public override void DropTable (TableSchema table) + { + ExecuteNonQuery ("DROP TABLE IF EXISTS " + table.Name + ";"); + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-dropview.html + public override void DropView (ViewSchema view) + { + ExecuteNonQuery ("DROP VIEW IF EXISTS " + view.Name + ";"); + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-dropindex.html + public override void DropIndex (IndexSchema index) + { + ExecuteNonQuery ("DROP INDEX IF EXISTS " + index.Name + " ON " + index.TableName + ";"); + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-droptrigger.html + public override void DropTrigger (TriggerSchema trigger) + { + ExecuteNonQuery ("DROP TRIGGER IF EXISTS " + trigger.Name + " ON " + trigger.TableName + ";"); + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-dropuser.html + public override void DropUser (UserSchema user) + { + ExecuteNonQuery ("DROP USER IF EXISTS " + user.Name + ";"); + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-alterdatabase.html + public override void RenameDatabase (DatabaseSchema database, string name) + { + ExecuteNonQuery ("ALTER DATABASE " + database.Name + " RENAME TO " + name + ";"); + + connectionPool.ConnectionContext.ConnectionSettings.Database = name; + database.Name = name; + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-altertable.html + public override void RenameTable (TableSchema table, string name) + { + ExecuteNonQuery ("ALTER TABLE " + table.Name + " RENAME TO " + name + ";"); + + table.Name = name; + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-altertable.html + public override void RenameView (ViewSchema view, string name) + { + //this is no copy paste error, it really is "ALTER TABLE"
+ ExecuteNonQuery ("ALTER TABLE " + view.Name + " RENAME TO " + name + ";"); + + view.Name = name; + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-altertrigger.html + public override void RenameTrigger (TriggerSchema trigger, string name) + { + ExecuteNonQuery ("ALTER TRIGGER " + trigger.Name + " ON " + trigger.TableName + " RENAME TO " + name + ";"); + + trigger.Name = name; + } + + //http://www.postgresql.org/docs/8.2/interactive/sql-alteruser.html + public override void RenameUser (UserSchema user, string name) + { + ExecuteNonQuery ("ALTER USER " + user.Name + " RENAME TO " + name + ";"); + + user.Name = name; + } + + public override string GetViewAlterStatement (ViewSchema view) + { + //'CREATE ' <-- after this we insert + return view.Definition.Insert (6, "OR REPLACE "); + } + + public override string GetProcedureAlterStatement (ProcedureSchema procedure) + { + //'CREATE ' <-- after this we insert + return procedure.Definition.Insert (6, "OR REPLACE "); + } + + /// <summary> + /// Last system OID used in postgres to monitor system vs user + /// objects. This varies based on the connections Server Version. + /// </summary> + protected int LastSystemOID { + get { + IPooledDbConnection conn = connectionPool.Request (); + NpgsqlConnection internalConn = conn.DbConnection as NpgsqlConnection; + int major = internalConn.ServerVersion.Major; + int minor = internalConn.ServerVersion.Minor; + conn.Release (); + + if (major == 8) + return 17137; + else if (major == 7 && minor == 1) + return 18539; + else if (major == 7 && minor == 2) + return 16554; + else if (major == 7 && minor == 3) + return 16974; + else if (major == 7 && minor == 4) + return 17137; + else + return 17137; + } + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/AssemblyInfo.cs.in b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/AssemblyInfo.cs.in new file mode 100644 index 0000000000..d905cc53d6 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/AssemblyInfo.cs.in @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("Mono.Data.Sql.Odbc")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("http://www.monodevelop.com")] +[assembly: AssemblyCopyright("MIT X11 - Christian Hergert, Daniel Morgan, Ben Motmans")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: AssemblyVersion("@ASSEMBLY_VERSION@")] + +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/ChangeLog b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/ChangeLog new file mode 100644 index 0000000000..8ad78a793b --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/ChangeLog @@ -0,0 +1,38 @@ +2007-10-29 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Odbc.addin.xml: Bump MD version. + +2007-10-23 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Odbc.mdp: Project file names updated by change in + MD path functions. + +2007-09-26 Michael Hutchinson <mhutchinson@novell.com> + + * MonoDevelop.Database.Sql.Odbc.mdp: Don't unnecessarily local-copy project + references. + +2007-09-21 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Odbc.addin.xml: Bump MD version. + +2007-07-10 Ben Motmans <ben.motmans@gmail.com> + + * OdbcConnectionProvider.cs: set IsConnectionError property + +2007-07-05 Ben Motmans <ben.motmans@gmail.com> + + * OdbcConnectionProvider.cs: ExecuteQueryAsDataSet and ExecuteQueryAsDataTable implementation + * OdbcDbFactory.cs: specified the ISqlDialect and added default connection settings + +2007-07-02 Ben Motmans <ben.motmans@gmail.com> + + * OdbcSchemaProvider.cs: + Imported the old DbProvider and updated all to code to use the new API + +2007-07-01 Ben Motmans <ben.motmans@gmail.com> + + * OdbcSchemaProvider.cs: + * OdbcDbFactory.cs: + * OdbcConnectionProvider.cs: + Imported original code and splitted in 3 classes diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/MonoDevelop.Database.Sql.Odbc.addin.xml b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/MonoDevelop.Database.Sql.Odbc.addin.xml new file mode 100644 index 0000000000..6189b1b228 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/MonoDevelop.Database.Sql.Odbc.addin.xml @@ -0,0 +1,21 @@ +<Addin id = "MonoDevelop.Database.Sql.Odbc" + namespace = "MonoDevelop" + name = "Odbc provider for Mono Data Sql" + author = "Christian Hergert, Daniel Morgan, Ben Motmans" + copyright = "MIT X11" + url = "http://www.monodevelop.com" + description = "Database Module" + version = "0.17.0"> + + <Runtime> + <Import assembly="MonoDevelop.Database.Sql.Odbc.dll"/> + </Runtime> + + <Dependencies> + <Addin id="MonoDevelop.Database.Sql" version="0.17.0"/> + </Dependencies> + + <Extension path = "/Mono/Data/Sql"> + <Class id = "Odbc" class = "MonoDevelop.Database.Sql.OdbcDbFactory"/> + </Extension> +</Addin>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/MonoDevelop.Database.Sql.Odbc.mdp b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/MonoDevelop.Database.Sql.Odbc.mdp new file mode 100644 index 0000000000..8907330d5c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/MonoDevelop.Database.Sql.Odbc.mdp @@ -0,0 +1,28 @@ +<Project name="MonoDevelop.Database.Sql.Odbc" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql.Odbc" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql.Odbc" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="OdbcConnectionProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="OdbcSchemaProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="MonoDevelop.Database.Sql.Odbc.addin.xml" subtype="Code" buildaction="FileCopy" /> + <File name="OdbcDbFactory.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema" subtype="Directory" buildaction="Compile" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Sql" /> + </References> +</Project>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/OdbcConnectionProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/OdbcConnectionProvider.cs new file mode 100644 index 0000000000..fb2a72f957 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/OdbcConnectionProvider.cs @@ -0,0 +1,111 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net> +// Daniel Morgan <danielmorgan@verizon.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc. +// Copyright (C) 2005 Daniel Morgan
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Data.Odbc;
+using System.Collections.Generic;
+
namespace MonoDevelop.Database.Sql
+{
+ public class OdbcConnectionProvider : AbstractConnectionProvider
+ {
+ public OdbcConnectionProvider (IDbFactory factory, ConnectionSettings settings)
+ : base (factory, settings)
+ {
+ } + + public override bool SupportsPooling {
+ get { return false; }
+ }
+
+ public override bool SupportsAutomaticConnectionString { + get { return false; } + } + + public override DataSet ExecuteQueryAsDataSet (string sql) + { + if (String.IsNullOrEmpty ("sql")) + throw new ArgumentException ("sql"); + + DataSet set = new DataSet (); + using (IDbCommand command = CreateCommand (sql)) { + using (OdbcDataAdapter adapter = new OdbcDataAdapter (command as OdbcCommand)) { + try { + adapter.Fill (set); + } catch { + } finally { + command.Connection.Close (); + } + } + } + return set; + } + + public override DataTable ExecuteQueryAsDataTable (string sql) + { + if (String.IsNullOrEmpty ("sql")) + throw new ArgumentException ("sql"); + + DataTable table = new DataTable (); + using (IDbCommand command = CreateCommand (sql)) { + using (OdbcDataAdapter adapter = new OdbcDataAdapter (command as OdbcCommand)) { + try { + adapter.Fill (table); + } catch { + } finally { + command.Connection.Close (); + } + } + } + return table; + }
+
+ public override IDbConnection Open (out string errorMessage)
+ {
+ string connStr = null;
+ try {
+ if (settings.UseConnectionString) { + connStr = settings.ConnectionString;
+ } else { + throw new NotImplementedException ();
+ }
+ connection = new OdbcConnection (connStr);
+ connection.Open ();
+
+ errorMessage = String.Empty;
+ isConnectionError = false;
+ return connection;
+ } catch { + isConnectionError = true;
+ errorMessage = String.Format ("Unable to connect. (CS={0})", connStr == null ? "NULL" : connStr);
+ return null;
+ }
+ }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/OdbcDbFactory.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/OdbcDbFactory.cs new file mode 100644 index 0000000000..70a73e216e --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/OdbcDbFactory.cs @@ -0,0 +1,73 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic;
+
namespace MonoDevelop.Database.Sql
+{
+ public class OdbcDbFactory : IDbFactory
+ { + private ISqlDialect dialect; + + public string Identifier { + get { return "System.Data.Odbc"; } + } +
+ public string Name { + get { return "ODBC data sources (Incomplete)"; } + } + + public ISqlDialect Dialect { + get { + if (dialect == null) + dialect = new Sql99Dialect ("\"", "@"); + return dialect; + } + } + + public IConnectionProvider CreateConnectionProvider (ConnectionSettings settings) + { + return new OdbcConnectionProvider (this, settings); + } + + public ISchemaProvider CreateSchemaProvider (IConnectionProvider connectionProvider) + { + return new OdbcSchemaProvider (connectionProvider); + } + + public ConnectionSettings GetDefaultConnectionSettings () + { + ConnectionSettings settings = new ConnectionSettings (); + settings.ProviderIdentifier = Identifier; + settings.Password = String.Empty; + settings.Database = String.Empty; + settings.Username = String.Empty; + settings.Server = String.Empty; + settings.Port = 0; + return settings; + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/OdbcSchemaProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/OdbcSchemaProvider.cs new file mode 100644 index 0000000000..9ae4d8e2af --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Odbc/OdbcSchemaProvider.cs @@ -0,0 +1,165 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net> +// Daniel Morgan <danielmorgan@verizon.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc. +// Copyright (C) 2005 Daniel Morgan
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Data.Odbc;
+using System.Collections.Generic;
+
namespace MonoDevelop.Database.Sql
+{
+ public class OdbcSchemaProvider : AbstractSchemaProvider
+ {
+ public OdbcSchemaProvider (IConnectionProvider connectionProvider)
+ : base (connectionProvider)
+ {
+ } + + public override bool SupportsSchemaType (Type type)
+ {
+ if (type == typeof(TableSchema)) + return true; + else if (type == typeof(ViewSchema)) + return true; + else if (type == typeof(ProcedureSchema)) + return true; + else if (type == typeof(AggregateSchema)) + return true; + else if (type == typeof(GroupSchema)) + return true; + else if (type == typeof(UserSchema)) + return true; + else if (type == typeof(LanguageSchema)) + return true; + else if (type == typeof(OperatorSchema)) + return true; + else if (type == typeof(RoleSchema)) + return true; + else if (type == typeof(SequenceSchema)) + return true; + else if (type == typeof(DataTypeSchema)) + return true; + else if (type == typeof(TriggerSchema)) + return true; + else if (type == typeof(ColumnSchema)) + return true; + else if (type == typeof(ConstraintSchema)) + return true; + else if (type == typeof(RuleSchema)) + return true; + else + return false;
+ }
+
+ public override ICollection<DatabaseSchema> GetDatabases ()
+ {
+ CheckConnectionState ();
+ List<DatabaseSchema> databases = new List<DatabaseSchema> (); + + //TODO:
+
+ return databases;
+ }
+
+ public override ICollection<TableSchema> GetTables ()
+ {
+ CheckConnectionState ();
+ List<TableSchema> tables = new List<TableSchema> ();
+
+ //TODO:
+
+ return tables;
+ }
+
+ public override ICollection<ColumnSchema> GetTableColumns (TableSchema table)
+ {
+ CheckConnectionState ();
+ List<ColumnSchema> columns = new List<ColumnSchema> ();
+
+ //TODO:
+
+ return columns;
+ }
+
+ public override ICollection<ViewSchema> GetViews ()
+ {
+ CheckConnectionState ();
+ List<ViewSchema> views = new List<ViewSchema> ();
+
+ //TODO:
+
+ return views;
+ }
+
+ public override ICollection<ColumnSchema> GetViewColumns (ViewSchema view)
+ {
+ CheckConnectionState ();
+ List<ColumnSchema> columns = new List<ColumnSchema> ();
+
+ //TODO:
+ return columns;
+ }
+
+ public override ICollection<ProcedureSchema> GetProcedures ()
+ {
+ CheckConnectionState ();
+ List<ProcedureSchema> procedures = new List<ProcedureSchema> ();
+
+ //TODO:
+
+ return procedures;
+ }
+
+ public override ICollection<ColumnSchema> GetProcedureColumns (ProcedureSchema procedure)
+ {
+ CheckConnectionState ();
+ List<ColumnSchema> columns = new List<ColumnSchema> ();
+
+ //TODO:
+
+ return columns;
+ }
+
+ public override ICollection<ParameterSchema> GetProcedureParameters (ProcedureSchema procedure)
+ {
+ CheckConnectionState (); + //TODO:
+ throw new NotImplementedException ();
+ }
+
+ public override ICollection<ConstraintSchema> GetTableConstraints (TableSchema table)
+ {
+ CheckConnectionState ();
+ List<ConstraintSchema> constraints = new List<ConstraintSchema> ();
+
+ //TODO:
+
+ return constraints;
+ }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/AssemblyInfo.cs.in b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/AssemblyInfo.cs.in new file mode 100644 index 0000000000..7c18acace4 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/AssemblyInfo.cs.in @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("Mono.Data.Sql.Odbc")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("http://www.monodevelop.com")] +[assembly: AssemblyCopyright("MIT X11 - Christian Hergert, Daniel Morgan, Ben Motmans")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: AssemblyVersion("@ASSEMBLY_VERSION@")] + +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")]
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/ChangeLog b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/ChangeLog new file mode 100644 index 0000000000..22e6f2daf4 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/ChangeLog @@ -0,0 +1,38 @@ +2007-10-29 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Oracle.addin.xml: Bump MD version. + +2007-10-23 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Oracle.mdp: Project file names updated by change + in MD path functions. + +2007-09-26 Michael Hutchinson <mhutchinson@novell.com> + + * MonoDevelop.Database.Sql.Oracle.mdp: Don't unnecessarily local-copy + project references. + +2007-09-21 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Oracle.addin.xml: Bump MD version. + +2007-07-10 Ben Motmans <ben.motmans@gmail.com> + + * OracleConnectionProvider.cs: set IsConnectionError property + +2007-07-05 Ben Motmans <ben.motmans@gmail.com> + + * OracleConnectionProvider.cs: ExecuteQueryAsDataSet and ExecuteQueryAsDataTable implementation + * OracleDbFactory.cs: specified the ISqlDialect and added default connection settings + +2007-07-02 Ben Motmans <ben.motmans@gmail.com> + + * OracleSchemaProvider.cs: + Imported the old DbProvider and updated all to code to use the new API + +2007-07-01 Ben Motmans <ben.motmans@gmail.com> + + * OracleSchemaProvider.cs: + * OracleDbFactory.cs: + * OracleConnectionProvider.cs: + Imported original code and splitted in 3 classes diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/MonoDevelop.Database.Sql.Oracle.addin.xml b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/MonoDevelop.Database.Sql.Oracle.addin.xml new file mode 100644 index 0000000000..34b3017a4e --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/MonoDevelop.Database.Sql.Oracle.addin.xml @@ -0,0 +1,21 @@ +<Addin id = "MonoDevelop.Database.Sql.Oracle" + namespace = "MonoDevelop" + name = "Oracle provider for Mono Data Sql" + author = "Christian Hergert, Daniel Morgan, Ben Motmans" + copyright = "MIT X11" + url = "http://www.monodevelop.com" + description = "Database Module" + version = "0.17.0"> + + <Runtime> + <Import assembly="MonoDevelop.Database.Sql.Oracle.dll"/> + </Runtime> + + <Dependencies> + <Addin id="MonoDevelop.Database.Sql" version="0.17.0"/> + </Dependencies> + + <Extension path = "/Mono/Data/Sql"> + <Class id = "Oracle" class = "MonoDevelop.Database.Sql.OracleDbFactory"/> + </Extension> +</Addin>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/MonoDevelop.Database.Sql.Oracle.mdp b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/MonoDevelop.Database.Sql.Oracle.mdp new file mode 100644 index 0000000000..3b771b75c1 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/MonoDevelop.Database.Sql.Oracle.mdp @@ -0,0 +1,29 @@ +<Project name="MonoDevelop.Database.Sql.Oracle" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql.Oracle" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql.Oracle" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="OracleConnectionProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="OracleSchemaProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="MonoDevelop.Database.Sql.Oracle.addin.xml" subtype="Code" buildaction="FileCopy" /> + <File name="OracleDbFactory.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema" subtype="Directory" buildaction="Compile" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Sql" /> + </References> +</Project>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/OracleConnectionProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/OracleConnectionProvider.cs new file mode 100644 index 0000000000..2e9a879e8c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/OracleConnectionProvider.cs @@ -0,0 +1,110 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net> +// Daniel Morgan <danielmorgan@verizon.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc. +// Copyright (C) 2005 Daniel Morgan
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Data.OracleClient;
+using System.Collections.Generic;
+
namespace MonoDevelop.Database.Sql
+{
+ public class OracleConnectionProvider : AbstractConnectionProvider
+ {
+ public OracleConnectionProvider (IDbFactory factory, ConnectionSettings settings)
+ : base (factory, settings)
+ {
+ } + + public override DataSet ExecuteQueryAsDataSet (string sql) + { + if (String.IsNullOrEmpty ("sql")) + throw new ArgumentException ("sql"); + + DataSet set = new DataSet (); + using (IDbCommand command = CreateCommand (sql)) { + using (OracleDataAdapter adapter = new OracleDataAdapter (command as OracleCommand)) { + try { + adapter.Fill (set); + } catch { + } finally { + command.Connection.Close (); + } + } + } + return set; + } + + public override DataTable ExecuteQueryAsDataTable (string sql) + { + if (String.IsNullOrEmpty ("sql")) + throw new ArgumentException ("sql"); + + DataTable table = new DataTable (); + using (IDbCommand command = CreateCommand (sql)) { + using (OracleDataAdapter adapter = new OracleDataAdapter (command as OracleCommand)) { + try { + adapter.Fill (table); + } catch { + } finally { + command.Connection.Close (); + } + } + } + return table; + }
+
+ public override IDbConnection Open (out string errorMessage)
+ {
+ string connStr = null;
+ try {
+ if (settings.UseConnectionString) { + connStr = settings.ConnectionString;
+ } else { + //Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;Integrated Security=no; + connStr = String.Format ("Data Source={0};User Id={1};Password={2};Integrated Security=no;", + settings.Database, settings.Username, settings.Password);
+ } + SetConnectionStringParameter (connStr, String.Empty, "pooling", settings.EnablePooling.ToString ()); + if (settings.EnablePooling) { + SetConnectionStringParameter (connStr, String.Empty, "Min Pool Size", settings.MinPoolSize.ToString ()); + SetConnectionStringParameter (connStr, String.Empty, "Max Pool Size", settings.MaxPoolSize.ToString ()); + }
+ connection = new OracleConnection (connStr);
+ connection.Open ();
+
+ errorMessage = String.Empty;
+ isConnectionError = false;
+ return connection;
+ } catch { + isConnectionError = true;
+ errorMessage = String.Format ("Unable to connect. (CS={0})", connStr == null ? "NULL" : connStr);
+ return null;
+ }
+ }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/OracleDbFactory.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/OracleDbFactory.cs new file mode 100644 index 0000000000..082ff05ed3 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/OracleDbFactory.cs @@ -0,0 +1,73 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic;
+
namespace MonoDevelop.Database.Sql
+{
+ public class OracleDbFactory : IDbFactory
+ { + private ISqlDialect dialect; + + public string Identifier { + get { return "System.Data.OracleClient"; } + } +
+ public string Name { + get { return "Oracle database (Incomplete)"; } + } + + public ISqlDialect Dialect { + get { + if (dialect == null) + dialect = new Sql99Dialect ("\"", ":"); + return dialect; + } + } + + public IConnectionProvider CreateConnectionProvider (ConnectionSettings settings) + { + return new OracleConnectionProvider (this, settings); + } + + public ISchemaProvider CreateSchemaProvider (IConnectionProvider connectionProvider) + { + return new OracleSchemaProvider (connectionProvider); + } + + public ConnectionSettings GetDefaultConnectionSettings () + { + ConnectionSettings settings = new ConnectionSettings (); + settings.ProviderIdentifier = Identifier; + settings.Port = 1521; + settings.Password = String.Empty; + settings.Database = String.Empty; + settings.Username = String.Empty; + //TODO: .Server property, not yet supported in the connection provider + return settings; + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/OracleSchemaProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/OracleSchemaProvider.cs new file mode 100644 index 0000000000..b95c650c50 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Oracle/OracleSchemaProvider.cs @@ -0,0 +1,304 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net> +// Daniel Morgan <danielmorgan@verizon.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc. +// Copyright (C) 2005 Daniel Morgan
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Text; +using System.Data;
+using System.Data.OracleClient;
+using System.Collections.Generic;
+
namespace MonoDevelop.Database.Sql
+{
+ public class OracleSchemaProvider : AbstractSchemaProvider
+ {
+ public OracleSchemaProvider (IConnectionProvider connectionProvider)
+ : base (connectionProvider)
+ {
+ } + + public override bool SupportsSchemaType (Type type)
+ {
+ if (type == typeof(TableSchema)) + return true; + else if (type == typeof(ColumnSchema)) + return true; + else if (type == typeof(ViewSchema)) + return true; + else if (type == typeof(ProcedureSchema)) + return true; + else if (type == typeof(UserSchema)) + return true; + else if (type == typeof(SequenceSchema)) + return true; + else if (type == typeof(TriggerSchema)) + return true; + else + return false;
+ }
+
+ public override ICollection<TableSchema> GetTables ()
+ {
+ CheckConnectionState ();
+ List<TableSchema> tables = new List<TableSchema> ();
+
+ IDbCommand command = connectionProvider.CreateCommand ( + "SELECT OWNER, TABLE_NAME, TABLESPACE_NAME " + + "FROM ALL_TABLES " + + "ORDER BY OWNER, TABLE_NAME" + );
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ TableSchema table = new TableSchema (this);
+
+ table.OwnerName = r.GetValue (0).ToString(); + table.SchemaName = r.GetValue (0).ToString(); + table.Name = r.GetString (1).ToString(); + table.IsSystemTable = IsSystem (table.OwnerName); + table.TableSpaceName = r.GetValue (2).ToString(); + + StringBuilder sb = new StringBuilder(); + sb.AppendFormat ("-- Table: {0}\n", table.Name); + sb.AppendFormat ("-- DROP TABLE {0};\n\n", table.Name); + sb.AppendFormat ("CREATE TABLE {0} (\n", table.Name); + + ICollection<ColumnSchema> columns = table.Columns; + string[] parts = new string[columns.Count]; + int i = 0;
+ foreach (ColumnSchema col in columns)
+ parts[i++] = col.Definition; + sb.Append (String.Join (",\n", parts)); + + ICollection<ConstraintSchema> constraints = table.Constraints; + parts = new string[constraints.Count]; + if (constraints.Count > 0) + sb.Append (",\n"); + i = 0;
+ foreach (ConstraintSchema constr in constraints)
+ parts[i++] = "\t" + constr.Definition; + sb.Append (String.Join (",\n", parts)); + + //sb.AppendFormat ("\n) COMMENT '{0}';", table.Comment); + table.Definition = sb.ToString ();
+
+ tables.Add (table);
+ } + r.Close ();
+ } + connectionProvider.Close (command.Connection);
+ }
+
+ return tables;
+ }
+
+ public override ICollection<ColumnSchema> GetTableColumns (TableSchema table)
+ {
+ CheckConnectionState ();
+ List<ColumnSchema> columns = new List<ColumnSchema> ();
+
+ IDbCommand command = connectionProvider.CreateCommand ( + "SELECT OWNER, TABLE_NAME, COLUMN_NAME, " + + " DATA_TYPE, DATA_LENGTH, DATA_PRECISION, DATA_SCALE, " + + " NULLABLE, COLUMN_ID, DEFAULT_LENGTH, DATA_DEFAULT " + + "FROM ALL_TAB_COLUMNS " + + "WHERE OWNER = '" + table.OwnerName + "' " + + "AND TABLE_NAME = '" + table.Name + "' " + + "ORDER BY OWNER, TABLE_NAME, COLUMN_ID" + );
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ColumnSchema column = new ColumnSchema (this);
+
+ column.Name = GetCheckedString (r, 2); + column.DataTypeName = GetCheckedString (r, 3); + column.OwnerName = table.OwnerName; + column.SchemaName = table.OwnerName; + column.NotNull = GetCheckedString (r, 7) == "Y"; + column.Length = GetCheckedInt32 (r, 4); + column.Precision = GetCheckedInt32 (r, 5); + column.Scale = GetCheckedInt32 (r, 6); + column.ColumnID = GetCheckedInt32 (r, 8); + + StringBuilder sb = new StringBuilder(); + sb.AppendFormat("{0} {1}{2}", + column.Name, + column.DataTypeName, + (column.Length > 0) ? ("(" + column.Length + ")") : ""); + sb.AppendFormat(" {0}", column.NotNull ? "NOT NULL" : "NULL"); + //if (column.Default.Length > 0) + // sb.AppendFormat(" DEFAULT {0}", column.Default); + column.Definition = sb.ToString();
+
+ columns.Add (column);
+ } + r.Close ();
+ }; + connectionProvider.Close (command.Connection);
+ }
+
+ return columns;
+ }
+
+ public override ICollection<ViewSchema> GetViews ()
+ {
+ CheckConnectionState ();
+ List<ViewSchema> views = new List<ViewSchema> ();
+
+ IDbCommand command = connectionProvider.CreateCommand (
+ "SELECT OWNER, VIEW_NAME, TEXT " + + "FROM ALL_VIEWS " + + "ORDER BY OWNER, VIEW_NAME"
+ );
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ViewSchema view = new ViewSchema (this);
+
+ view.Name = r.GetString(1); + view.SchemaName = r.GetString (0); + view.OwnerName = r.GetString (0); + view.Definition = r.GetString (2); + view.IsSystemView = IsSystem (view.OwnerName); +
+ views.Add (view);
+ } + r.Close ();
+ } + connectionProvider.Close (command.Connection);
+ }
+ return views;
+ }
+
+ public override ICollection<ColumnSchema> GetViewColumns (ViewSchema view)
+ {
+ CheckConnectionState ();
+ List<ColumnSchema> columns = new List<ColumnSchema> ();
+
+ IDbCommand command = connectionProvider.CreateCommand ( + "SELECT * " + + " FROM " + view.Name + + " WHERE 1 = 0" + );
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) { + for (int i = 0; i < r.FieldCount; i++) { + ColumnSchema column = new ColumnSchema (this); + + column.Name = r.GetString (0); + column.DataTypeName = r.GetString (1); + column.SchemaName = view.SchemaName; + column.NotNull = r.GetBoolean (3); + column.Length = r.GetInt32 (2); + + columns.Add (column); + }
+ } + r.Close ();
+ }; + connectionProvider.Close (command.Connection);
+ }
+
+ return columns;
+ }
+
+ public override ICollection<ConstraintSchema> GetTableConstraints (TableSchema table)
+ {
+ CheckConnectionState ();
+ List<ConstraintSchema> constraints = new List<ConstraintSchema> ();
+
+ IDbCommand command = connectionProvider.CreateCommand ( + "SELECT k.owner, k.table_name, k.constraint_name, " + + " k.constraint_type, k.status, k.validated " + + "FROM all_constraints k " + + "WHERE k.owner = '" + table.OwnerName + "' " + + "AND k.table_name = '" + table.Name + "' " + + "and k.constraint_type = 'P'" + );
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) { + while (r.Read ()) { + ConstraintSchema constraint = null; + + switch (r.GetString(4)) { + case "P": + default: + constraint = new PrimaryKeyConstraintSchema (this); + break; + } + + constraint.Name = r.GetString (3); + constraint.Definition = ""; + + constraints.Add (constraint); + } + r.Close ();
+ } + connectionProvider.Close (command.Connection);
+ }
+
+ return constraints;
+ }
+
+ public override DataTypeSchema GetDataType (string name)
+ {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+ name = name.ToUpper ();
+
+ DataTypeSchema dts = new DataTypeSchema (this);
+ dts.Name = name;
+ switch (name) {
+ //TODO: IMPLEMENT
+ case "":
+ break;
+ default:
+ dts = null; + break;
+ }
+
+ return dts;
+ } + + private bool IsSystem (string owner) + { + switch (owner) { + case "SYSTEM": + case "SYS": + case "DRSYS": + case "CTXSYS": + case "MDSYS": + case "WKSYS": + return true; + default: + return false; + } + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/AssemblyInfo.cs.in b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/AssemblyInfo.cs.in new file mode 100644 index 0000000000..7a3a8a3a72 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/AssemblyInfo.cs.in @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("MonoDevelop.Database.Sql.MsSql")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("http://www.monodevelop.com")] +[assembly: AssemblyCopyright("MIT X11 - Christian Hergert, Daniel Morgan, Sureshkumar T, Ben Motmans")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: AssemblyVersion("@ASSEMBLY_VERSION@")] + +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/ChangeLog b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/ChangeLog new file mode 100644 index 0000000000..ca9292810d --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/ChangeLog @@ -0,0 +1,123 @@ +2007-11-09 Michael Hutchinson <mhutchinson@novell.com> + + * SqlServerSchemaProvider.cs: Track LoggingService API. Replace some + "LogError" calls with "LogDebug" calls. + +2007-10-29 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.SqlServer.addin.xml: Bump MD version. + +2007-10-23 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.SqlServer.mdp: Project file names updated by + change in MD path functions. + +2007-10-16 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.SqlServer.mdp: Fix required GTK# version. + +2007-09-26 Michael Hutchinson <mhutchinson@novell.com> + + * Makefile.am: Don't deploy .addin.xml file. + * MonoDevelop.Database.Sql.SqlServer.mdp: Don't unnecessarily local-copy + project references. Don't sync EXTRA_DIST with deploy files. Add + Makefile.am to file list. + +2007-09-21 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.SqlServer.addin.xml: Bump MD version. + +2007-09-19 Ben Motmans <ben.motmans@gmail.com> + + * SqlServerConnectionProvider.cs: commented the NetworkLibrary property in + the connection string + * SqlServerSchemaProvider.cs: catch errors and several bugfixes + * MonoDevelop.Database.Sql.SqlServer.addin.xml: SqlServer doesn't support + procedure parameters yet + +2007-09-16 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: link to the correct Mono.Addins dll + +2007-09-07 Ben Motmans <ben.motmans@gmail.com> + + * SqlServerSchemaProvider.cs, SqlServerDbFactory.cs, + MonoDevelop.Database.Sql.SqlServer.addin.xml: improved capabilities + system + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am, MonoDevelop.Database.Sql.SqlServer.mdp: use project + references instead of assembly references + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: updated makefile + +2007-08-03 Ben Motmans <ben.motmans@gmail.com> + + * SqlServerConnectionProvider.cs: added support for an error message + * SqlServerSchemaProvider.cs: added MetaData information + +2007-08-01 Ben Motmans <ben.motmans@gmail.com> + + * SqlServerSchemaProvider.cs: Catch exceptions and notify the user + +2007-07-31 Ben Motmans <ben.motmans@gmail.com> + + * SqlServerDbFactory.cs, SqlServerGuiProvider.cs: Added a GuiProvider + * SqlServerSchemaProvider.cs: small api changes + +2007-07-25 Ben Motmans <ben.motmans@gmail.com> + + * SqlServerPooledDbConnection.cs: expose the GetSchema method of the internal connection + * SqlServerDbFactory.cs, SqlServerSchemaProvider.cs: improved metadata support + +2007-07-18 Ben Motmans <ben.motmans@gmail.com> + + * SqlServerSchemaProvider.cs: SupportsSchemaOperation implementation, use of strongly typed + collections, Drop* and Rename* implementations + +2007-07-17 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: initial makefile + * SqlServerDbFactory.cs: implemented methods required for the connection settings dialog + +2007-07-15 Ben Motmans <ben.motmans@gmail.com> + + * SqlServerDialect.cs: dialect implementation with keyword detection + * SqlServerDbFactory.cs: use SqlServerDialect instead of the obsolete Sql99Dialect + +2007-07-14 Ben Motmans <ben.motmans@gmail.com> + + * SqlServerConnectionProvider.cs, SqlServerDbFactory.cs, SqlServerSchemaProvider.cs: small changes + to reflect API changes + * SqlServerPooledDbConnection.cs: implementation of ConnectionPool aware connection + +2007-07-10 Ben Motmans <ben.motmans@gmail.com> + + * SqlServerConnectionProvider.cs: set IsConnectionError property + +2007-07-05 Ben Motmans <ben.motmans@gmail.com> + + * SqlServerConnectionProvider.cs: ExecuteQueryAsDataSet and ExecuteQueryAsDataTable implementation + * SqlServerDbFactory.cs: specified the ISqlDialect and added default connection settings + * Renamed MsSql* to SqlServer* + +2007-07-02 Ben Motmans <ben.motmans@gmail.com> + + * MsSqlConnectionProvider.cs: + * MsSqlSchemaProvider.cs: + Fixed several compilation issues + Added Close () statements when the IDataReader is no longer needed + +2007-07-01 Ben Motmans <ben.motmans@gmail.com> + + * MsSqlSchemaProvider.cs: + * MsSqlDbFactory.cs: + * MsSqlConnectionProvider.cs: + Imported original code and splitted in 3 classes + use IsDbNull instead of try-catch + fixed sql bug in GetTableColumns method + implemented GetDataType, GetDatabases, GetConstraints method + updated sql statements to allow lazy loading diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/Makefile.am b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/Makefile.am new file mode 100644 index 0000000000..e5ff9df23a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/Makefile.am @@ -0,0 +1,46 @@ +ADDIN_BUILD = $(top_builddir)/build/AddIns/MonoDevelop.Database +ASSEMBLY = $(ADDIN_BUILD)/MonoDevelop.Database.Sql.SqlServer.dll +REFS = \ + $(GTK_SHARP_LIBS) \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Components.dll \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Designer.dll \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Sql.dll \ + -r:$(top_builddir)/build/bin/Mono.Addins.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Components.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.Gui.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Ide.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Projects.dll \ + -r:System \ + -r:System.Data + +FILES = \ + SqlServerConnectionProvider.cs \ + SqlServerDbFactory.cs \ + SqlServerDialect.cs \ + SqlServerGuiProvider.cs \ + SqlServerPooledDbConnection.cs \ + SqlServerSchemaProvider.cs + +RES = MonoDevelop.Database.Sql.SqlServer.addin.xml + +if ENABLE_SQLSERVER +all: $(ASSEMBLY) +else
+all:
+endif + +$(ASSEMBLY): $(FILES) $(build_resources) + mkdir -p $(ADDIN_BUILD) + $(CSC) $(CSC_FLAGS) $(REFS) $(build_resources:%=/resource:%) $(build_sources) -out:$@ -target:library + + +if ENABLE_DATABASE +assemblydir = $(MD_ADDIN_DIR)/MonoDevelop.Database +assembly_DATA = $(ASSEMBLY) +endif + +CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb +EXTRA_DIST = $(FILES) $(RES) + +include $(top_srcdir)/Makefile.include diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/MonoDevelop.Database.Sql.SqlServer.addin.xml b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/MonoDevelop.Database.Sql.SqlServer.addin.xml new file mode 100644 index 0000000000..1ace611a28 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/MonoDevelop.Database.Sql.SqlServer.addin.xml @@ -0,0 +1,65 @@ +<Addin id = "Database.Sql.SqlServer" + namespace = "MonoDevelop" + name = "SqlServer provider for Mono Data Sql" + author = "Christian Hergert, Daniel Morgan, Sureshkumar T, Ben Motmans" + copyright = "MIT X11" + url = "http://www.monodevelop.com" + description = "Database Module" + version = "0.17.0"> + + <Runtime> + <Import assembly="MonoDevelop.Database.Sql.SqlServer.dll"/> + </Runtime> + + <Dependencies> + <Addin id="Core" version="0.17.0"/> + <Addin id="Core.Gui" version="0.17.0"/> + <Addin id="Ide" version="0.17.0"/> + <Addin id="Database.Sql" version="0.17.0"/> + <Addin id="Database.Components" version="0.17.0"/> + <Addin id="Database.Designer" version="0.17.0"/> + </Dependencies> + + <Extension path = "/MonoDevelop/Database/Sql"> + <DatabaseFactory id = "SqlServer" class = "MonoDevelop.Database.Sql.SqlServerDbFactory"> + <!-- action flags --> + <Actions category="Database" flags="All" /> + <Actions category="Table" flags="Create,Drop,Rename,Schema" /> + <Actions category="View" flags="All" /> + <Actions category="Procedure" flags="All" /> + <Actions category="TableColumn" flags="All" /> + <Actions category="Parameter" flags="Schema" /> + <Actions category="Trigger" flags="All" /> + <Actions category="PrimaryKeyConstraint" flags="Create,Drop,Rename,Schema" /> + <Actions category="ForeignKeyConstraint" flags="Create,Drop,Rename,Schema" /> + <Actions category="CheckConstraint" flags="Create,Drop,Rename,Schema" /> + <Actions category="UniqueConstraint" flags="Create,Drop,Rename,Schema" /> + <Actions category="User" flags="Schema" /> + + <!-- ConnectionSettings capabilities --> + <Capabilities category="ConnectionSettings" action="Schema" flags="Username,Password,Server,Port,ListDatabases" /> + <!-- table capabilities --> + <Capabilities category="Table" action="All" flags="Name,Definition,Schema,IsSystem,Columns,Constraints,Trigger" /> + <Capabilities category="Table" action="Alter" flags="AppendConstraint,InsertConstraint,RemoveConstraint,AppendTrigger,InsertTrigger,RemoveTrigger,AppendColumn,InsertColumn,RemoveColumn" /> + <!-- Table Column capabilities --> + <Capabilities category="TableColumn" action="All" flags="Name,Definition,Schema,DataType,DefaultValue,Nullable,Position,Constraints" /> + <Capabilities category="TableColumn" action="Alter" flags="AppendConstraint,InsertConstraint,RemoveConstraint" /> + <!-- Procedure capabilities --> + <Capabilities category="Procedure" action="All" flags="Name,Definition,Schema,IsSystem" /> + <Capabilities category="Procedure" action="Alter" flags="InsertParameter,AppendParameter,RemoveParameter" /> + <!-- View capabilities --> + <Capabilities category="View" action="All" flags="Name,Definition,Schema,Statement,IsSystem" /> + <Capabilities category="View" action="Schema" flags="Columns" /> + <!-- Trigger capabilities --> + <Capabilities category="Trigger" action="All" flags="Name,Definition,Schema,TableName,TriggerType,TriggerEvent,TriggerFireType,Position,IsActive,Source" /> + <!-- PrimaryKeyConstraint capabilities --> + <Capabilities category="PrimaryKeyConstraint" action="All" flags="Name,Columns,IsColumnConstraint" /> + <!-- ForeignKeyConstraint capabilities --> + <Capabilities category="ForeignKeyConstraint" action="All" flags="Name,Columns,IsColumnConstraint,ReferenceTable,ReferenceColumns,Cascade,NoAction" /> + <!-- CheckConstraint capabilities --> + <Capabilities category="CheckConstraint" action="All" flags="Name,Columns,IsColumnConstraint,Source" /> + <!-- UniqueConstraint capabilities --> + <Capabilities category="UniqueConstraint" action="All" flags="Name,Columns,IsColumnConstraint" /> + </DatabaseFactory> + </Extension> +</Addin> diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/MonoDevelop.Database.Sql.SqlServer.mdp b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/MonoDevelop.Database.Sql.SqlServer.mdp new file mode 100644 index 0000000000..c93e89b598 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/MonoDevelop.Database.Sql.SqlServer.mdp @@ -0,0 +1,52 @@ +<Project name="MonoDevelop.Database.Sql.SqlServer" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql.SqlServer" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql.SqlServer" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="SqlServerConnectionProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="SqlServerSchemaProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="SqlServerDbFactory.cs" subtype="Code" buildaction="Compile" /> + <File name="SqlServerPooledDbConnection.cs" subtype="Code" buildaction="Compile" /> + <File name="SqlServerDialect.cs" subtype="Code" buildaction="Compile" /> + <File name="SqlServerGuiProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="MonoDevelop.Database.Sql.SqlServer.addin.xml" subtype="Code" buildaction="EmbedAsResource" /> + <File name="Makefile.am" subtype="Code" buildaction="Nothing" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Sql" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Components" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Designer" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core.Gui" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Ide" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Projects" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Components" /> + <ProjectReference type="Project" localcopy="False" refto="Mono.Addins" /> + <ProjectReference type="Gac" localcopy="True" refto="pango-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="atk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + </References> + <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am" BuildTargetName="" CleanTargetName="" SyncReferences="True" IsAutotoolsProject="True" RelativeConfigureInPath="../../../"> + <BuildFilesVar Sync="True" Name="FILES" /> + <DeployFilesVar /> + <ResourcesVar Sync="True" Name="RES" /> + <OthersVar /> + <GacRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <AsmRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <ProjectRefVar Sync="True" Name="REFS" Prefix="-r:" /> + </MonoDevelop.Autotools.MakefileInfo> +</Project>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerConnectionProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerConnectionProvider.cs new file mode 100755 index 0000000000..462813ff18 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerConnectionProvider.cs @@ -0,0 +1,62 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Data.SqlClient;
+using System.Collections.Generic;
+
namespace MonoDevelop.Database.Sql
+{
+ public class SqlServerConnectionProvider : AbstractConnectionProvider
+ {
+ public override IPooledDbConnection CreateConnection (IConnectionPool pool, DatabaseConnectionSettings settings, out string error)
+ {
+ SqlConnectionStringBuilder builder = null;
+ try {
+ if (settings.UseConnectionString) {
+ builder = new SqlConnectionStringBuilder (settings.ConnectionString);
+ } else {
+ builder = new SqlConnectionStringBuilder ();
+ builder.InitialCatalog = settings.Database;
+ builder.UserID = settings.Username;
+ builder.Password = settings.Password;
+ builder.DataSource = String.Concat (settings.Server, ",", settings.Port);
+ //builder.NetworkLibrary = "DBMSSOCN";
+ }
+ builder.Pooling = false;
+ SqlConnection connection = new SqlConnection (builder.ToString ());
+ connection.Open ();
+ + error = null;
+ return new SqlServerPooledDbConnection (pool, connection);
+ } catch (Exception e) { + error = e.Message;
+ return null;
+ }
+ }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerDbFactory.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerDbFactory.cs new file mode 100644 index 0000000000..6b0f4f28d3 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerDbFactory.cs @@ -0,0 +1,94 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+ +using System;
+using System.Data;
+using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Database.Components;
+
namespace MonoDevelop.Database.Sql
+{
+ public class SqlServerDbFactory : AbstractDbFactory
+ { + private ISqlDialect dialect; + private IConnectionProvider connectionProvider; + private IGuiProvider guiProvider; + + public override string Identifier { + get { return "System.Data.SqlClient"; } + } +
+ public override string Name { + get { return "SQL Server database"; } + } + + public override ISqlDialect Dialect { + get { + if (dialect == null) + dialect = new SqlServerDialect (); + return dialect; + } + } + + public override IConnectionProvider ConnectionProvider { + get { + if (connectionProvider == null) + connectionProvider = new SqlServerConnectionProvider (); + return connectionProvider; + } + } + + public override IGuiProvider GuiProvider { + get { + if (guiProvider == null) + guiProvider = new SqlServerGuiProvider (); + return guiProvider; + } + } + + public override IConnectionPool CreateConnectionPool (DatabaseConnectionContext context) + { + return new DefaultConnectionPool (this, ConnectionProvider, context); + } + + public override ISchemaProvider CreateSchemaProvider (IConnectionPool connectionPool) + { + return new SqlServerSchemaProvider (connectionPool); + } + + public override DatabaseConnectionSettings GetDefaultConnectionSettings () + { + DatabaseConnectionSettings settings = new DatabaseConnectionSettings (); + settings.ProviderIdentifier = Identifier; + settings.Server = "localhost"; + settings.Port = 1433; + settings.Username = "sa"; + settings.MaxPoolSize = 5; + + return settings; + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerDialect.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerDialect.cs new file mode 100644 index 0000000000..587e24f7a8 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerDialect.cs @@ -0,0 +1,135 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic; +
namespace MonoDevelop.Database.Sql
+{
+ public class SqlServerDialect : AbstractSqlDialect
+ { + //http://msdn2.microsoft.com/En-US/library/aa224033(SQL.80).aspx + public override string QuoteIdentifier (string identifier) + { + if (identifier == null) + throw new ArgumentNullException ("identifier"); + + if (IsReservedWord (identifier)) + return String.Concat ('[', identifier, ']'); + + foreach (char c in identifier.ToCharArray ()) { + switch (c) { + case ' ': case '~': case '-': + case '!': case '{': case '%': + case '}': case '^': case '\'': + case '&': case '.': case '(': + case '\\': case ')': case '`': + return String.Concat ('[', identifier, ']'); + default: + break; + } + } + return identifier; + } + + public override string MarkAsParameter (string identifier) + { + if (identifier == null) + throw new ArgumentNullException ("identifier"); + + return "@" + identifier; + } + + //http://msdn2.microsoft.com/en-US/library/aa238507(SQL.80).aspx + protected virtual bool IsReservedWord (string word) + { + word = word.ToUpper (); + + switch (word) { + case "EXCEPT": case "PERCENT": + case "ALL": case "EXEC": case "PLAN": + case "ALTER": case "EXECUTE": case "PRECISION": + case "AND": case "EXISTS": case "PRIMARY": + case "ANY": case "EXIT": case "PRINT": + case "AS": case "FETCH": case "PROC": + case "ASC": case "FILE": case "PROCEDURE": + case "AUTHORIZATION": case "FILLFACTOR": case "PUBLIC": + case "BACKUP": case "FOR": case "RAISERROR": + case "BEGIN": case "FOREIGN": case "READ": + case "BETWEEN": case "FREETEXT": case "READTEXT": + case "BREAK": case "FREETEXTTABLE": case "RECONFIGURE": + case "BROWSE": case "FROM": case "REFERENCES": + case "BULK": case "FULL": case "REPLICATION": + case "BY": case "FUNCTION": case "RESTORE": + case "CASCADE": case "GOTO": case "RESTRICT": + case "CASE": case "GRANT": case "RETURN": + case "CHECK": case "GROUP": case "REVOKE": + case "CHECKPOINT": case "HAVING": case "RIGHT": + case "CLOSE": case "HOLDLOCK": case "ROLLBACK": + case "CLUSTERED": case "IDENTITY": case "ROWCOUNT": + case "COALESCE": case "IDENTITY_INSERT": case "ROWGUIDCOL": + case "COLLATE": case "IDENTITYCOL": case "RULE": + case "COLUMN": case "IF": case "SAVE": + case "COMMIT": case "IN": case "SCHEMA": + case "COMPUTE": case "INDEX": case "SELECT": + case "CONSTRAINT": case "INNER": case "SESSION_USER": + case "CONTAINS": case "INSERT": case "SET": + case "CONTAINSTABLE": case "INTERSECT": case "SETUSER": + case "CONTINUE": case "INTO": case "SHUTDOWN": + case "CONVERT": case "IS": case "SOME": + case "CREATE": case "JOIN": case "STATISTICS": + case "CROSS": case "KEY": case "SYSTEM_USER": + case "CURRENT": case "KILL": case "TABLE": + case "CURRENT_DATE": case "LEFT": case "TEXTSIZE": + case "CURRENT_TIME": case "LIKE": case "THEN": + case "CURRENT_TIMESTAMP": case "LINENO": case "TO": + case "CURRENT_USER": case "LOAD": case "TOP": + case "CURSOR": case "NATIONAL ": case "TRAN": + case "DATABASE": case "NOCHECK": case "TRANSACTION": + case "DBCC": case "NONCLUSTERED": case "TRIGGER": + case "DEALLOCATE": case "NOT": case "TRUNCATE": + case "DECLARE": case "NULL": case "TSEQUAL": + case "DEFAULT": case "NULLIF": case "UNION": + case "DELETE": case "OF": case "UNIQUE": + case "DENY": case "OFF": case "UPDATE": + case "DESC": case "OFFSETS": case "UPDATETEXT": + case "DISK": case "ON": case "USE": + case "DISTINCT": case "OPEN": case "USER": + case "DISTRIBUTED": case "OPENDATASOURCE": case "VALUES": + case "DOUBLE": case "OPENQUERY": case "VARYING": + case "DROP": case "OPENROWSET": case "VIEW": + case "DUMMY": case "OPENXML": case "WAITFOR": + case "DUMP": case "OPTION": case "WHEN": + case "ELSE": case "OR": case "WHERE": + case "END": case "ORDER": case "WHILE": + case "ERRLVL": case "OUTER": case "WITH": + case "ESCAPE": case "OVER": case "WRITETEXT": + return true; + default: + return false; + } + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerGuiProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerGuiProvider.cs new file mode 100644 index 0000000000..2ab698ee3c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerGuiProvider.cs @@ -0,0 +1,74 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using Gtk; +using System;
+using System.Data;
+using System.Collections.Generic; +using MonoDevelop.Database.Designer; +using MonoDevelop.Database.Components;
+
namespace MonoDevelop.Database.Sql
+{
+ public class SqlServerGuiProvider : IGuiProvider
+ { + public bool ShowSelectDatabaseDialog (bool create, out string database) + { + database = null; + return false; + } + + public bool ShowTableEditorDialog (ISchemaProvider schemaProvider, TableSchema table, bool create) + { + return RunDialog (new TableEditorDialog (schemaProvider, table, create)); + } + + public bool ShowViewEditorDialog (ISchemaProvider schemaProvider, ViewSchema view, bool create) + { + return RunDialog (new ViewEditorDialog (schemaProvider, view, create)); + } + + public bool ShowProcedureEditorDialog (ISchemaProvider schemaProvider, ProcedureSchema procedure, bool create) + { + return RunDialog (new ProcedureEditorDialog (schemaProvider, procedure, create)); + } + + public bool ShowUserEditorDialog (ISchemaProvider schemaProvider, UserSchema user, bool create) + { + return RunDialog (new UserEditorDialog (schemaProvider, user, create)); + } + + private bool RunDialog (Dialog dlg) + { + bool result = false; + try { + if (dlg.Run () == (int)ResponseType.Ok) + result = true; + } finally { + dlg.Destroy (); + } + return result; + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerPooledDbConnection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerPooledDbConnection.cs new file mode 100644 index 0000000000..3cebc295a6 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerPooledDbConnection.cs @@ -0,0 +1,81 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data; +using System.Data.SqlClient;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class SqlServerPooledDbConnection : AbstractPooledDbConnection
+ { + public SqlServerPooledDbConnection (IConnectionPool connectionPool, IDbConnection connection) + : base (connectionPool, connection) + { + } + + public override DataSet ExecuteSet (IDbCommand command) + { + if (command == null) + throw new ArgumentException ("command"); + + DataSet set = new DataSet (); + using (command) { + using (SqlDataAdapter adapter = new SqlDataAdapter (command as SqlCommand)) { + try { + adapter.Fill (set); + } catch (Exception e) { + QueryService.RaiseException (e); + } + } + } + return set; + } + + public override DataTable ExecuteTable (IDbCommand command) + { + if (command == null) + throw new ArgumentException ("command"); + + DataTable table = new DataTable (); + using (command) { + using (SqlDataAdapter adapter = new SqlDataAdapter (command as SqlCommand)) { + try { + adapter.Fill (table); + } catch (Exception e) { + QueryService.RaiseException (e); + } + } + } + return table; + } + + public override DataTable GetSchema (string collectionName, params string[] restrictionValues) + { + return (connection as SqlConnection).GetSchema (collectionName, restrictionValues); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerSchemaProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerSchemaProvider.cs new file mode 100755 index 0000000000..490df255b9 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.SqlServer/SqlServerSchemaProvider.cs @@ -0,0 +1,860 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Daniel Morgan <danielmorgan@verizon.net>
+// Sureshkumar T <tsureshkumar@novell.com>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEC
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Text;
+using System.Data;
+using System.Data.SqlClient;
+using System.Collections.Generic; +using MonoDevelop.Core;
+
namespace MonoDevelop.Database.Sql
+{ + // see: + // http://www.alberton.info/sql_server_meta_info.html + msdn
+ public class SqlServerSchemaProvider : AbstractSchemaProvider
+ {
+ public SqlServerSchemaProvider (IConnectionPool connectionPool)
+ : base (connectionPool)
+ {
+ }
+
+ public override DatabaseSchemaCollection GetDatabases ()
+ {
+ DatabaseSchemaCollection databases = new DatabaseSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request (); + conn.DbConnection.ChangeDatabase ("master"); //we don't have to change it back afterwards, since the connectionpool will do this for us + IDbCommand command = conn.CreateCommand ("select name from sysdatabases"); + try { + using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read()) {
+ DatabaseSchema db = new DatabaseSchema (this);
+ db.Name = r.GetString (0);
+ databases.Add (db);
+ }
+ r.Close (); + } + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return databases;
+ }
+
+ public override TableSchemaCollection GetTables ()
+ {
+ TableSchemaCollection tables = new TableSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand (
+ "SELECT su.name AS owner, so.name as table_name, so.id as table_id, " +
+ " so.crdate as created_date, so.xtype as table_type " +
+ " FROM dbo.sysobjects so, dbo.sysusers su " +
+ "WHERE xtype IN ('S','U') " +
+ "AND su.uid = so.uid " +
+ "ORDER BY 1, 2"
+ ); + try { + using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read()) {
+ TableSchema table = new TableSchema (this); +
+ table.Name = r.GetString(1);
+ table.IsSystemTable = r.GetString(4) == "S" ? true : false;
+ table.OwnerName = r.GetString(0); + table.Definition = GetTableDefinition (table);
+
+ tables.Add (table);
+ } + r.Close (); + }
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return tables;
+ }
+
+ public override ColumnSchemaCollection GetTableColumns (TableSchema table)
+ {
+ ColumnSchemaCollection columns = new ColumnSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand (
+ "SELECT su.name as owner, so.name as table_name, " +
+ " sc.name as column_name, " +
+ " st.name as date_type, sc.length as column_length, " +
+ " sc.xprec as data_precision, sc.xscale as data_scale, " +
+ " sc.isnullable, sc.colid as column_id " +
+ "FROM dbo.syscolumns sc, dbo.sysobjects so, " +
+ " dbo.systypes st, dbo.sysusers su " +
+ "WHERE sc.id = so.id " +
+ "AND so.xtype in ('U','S') " +
+ "AND so.name = '" + table.Name + "' " +
+ "AND su.name = '" + table.OwnerName + "' " +
+ "AND sc.xusertype = st.xusertype " +
+ "AND su.uid = so.uid " +
+ "ORDER BY sc.colid"
+ ); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read()) {
+ ColumnSchema column = new ColumnSchema (this, table);
+
+ column.Name = r.GetString (2);
+ column.DataTypeName = r.GetString (3);
+ column.DefaultValue = String.Empty;
+ column.Comment = String.Empty;
+ column.OwnerName = table.OwnerName;
+ column.SchemaName = table.SchemaName;
+ column.IsNullable = r.GetValue (7).ToString () == "0" ? true : false;
+ column.DataType.LengthRange.Default = r.GetInt16 (4);
+ column.DataType.PrecisionRange.Default = r.IsDBNull (5) ? 0 : (int)r.GetByte (5);
+ column.DataType.ScaleRange.Default = r.IsDBNull (6) ? 0 : (int)r.GetByte (6);
+ column.Definition = String.Concat (column.Name, " ", column.DataTypeName, " ",
+ column.DataType.LengthRange.Default > 0 ? "(" + column.DataType.LengthRange.Default + ")" : "",
+ column.IsNullable ? " NULL" : " NOT NULL");
+ //TODO: append " DEFAULT ..." if column.Default.Length > 0
+
+ columns.Add (column);
+ } + r.Close ();
+ } + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return columns;
+ }
+
+ public override ViewSchemaCollection GetViews ()
+ {
+ ViewSchemaCollection views = new ViewSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand (
+ "SELECT su.name AS owner, so.name as table_name, so.id as table_id, " +
+ " so.crdate as created_date, so.xtype as table_type " +
+ "FROM dbo.sysobjects so, dbo.sysusers su " +
+ "WHERE xtype = 'V' " +
+ "AND su.uid = so.uid " +
+ "ORDER BY 1, 2"
+ ); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read()) {
+ ViewSchema view = new ViewSchema (this);
+
+ view.Name = r.GetString (1);
+ view.SchemaName = r.GetString (0);
+ view.OwnerName = r.GetString (0); + + StringBuilder sb = new StringBuilder();
+ sb.AppendFormat ("-- View: {0}\n", view.Name);
+ sb.AppendFormat ("-- DROP VIEW {0};\n\n", view.Name);
+ sb.AppendFormat (" {0}\n);", GetSource ("[" + view.OwnerName + "].[" + view.Name + "]"));
+ view.Definition = sb.ToString ();
+
+ views.Add (view);
+ } + r.Close ();
+ } + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return views;
+ }
+
+ public override ColumnSchemaCollection GetViewColumns (ViewSchema view)
+ {
+ ColumnSchemaCollection columns = new ColumnSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand (
+ "SELECT * FROM \"" + view.Name +
+ "\" WHERE 1 = 0"
+ ); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ for (int i = 0; i < r.FieldCount; i++) {
+ ColumnSchema column = new ColumnSchema (this, view);
+
+ column.Name = r.GetName(i);
+ column.DataTypeName = r.GetDataTypeName(i);
+ column.DefaultValue = "";
+ column.Definition = "";
+ column.OwnerName = view.OwnerName;
+ column.SchemaName = view.OwnerName;
+
+ columns.Add (column);
+ } + r.Close (); + } + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release (); +
+ return columns;
+ }
+
+ public override ProcedureSchemaCollection GetProcedures ()
+ {
+ ProcedureSchemaCollection procedures = new ProcedureSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand (
+ "SELECT su.name AS owner, so.name as proc_name, so.id as proc_id, " +
+ " so.crdate as created_date, so.xtype as proc_type " +
+ "FROM dbo.sysobjects so, dbo.sysusers su " +
+ "WHERE xtype = 'P' " +
+ "AND su.uid = so.uid " +
+ "ORDER BY 1, 2"
+ ); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ProcedureSchema procedure = new ProcedureSchema (this);
+ procedure.Name = r.GetString (1);
+ procedure.OwnerName = r.GetString (0);
+ procedure.LanguageName = "TSQL"; + + StringBuilder sb = new StringBuilder();
+ sb.AppendFormat ("-- Procedure: {0}\n", procedure.Name);
+ sb.AppendFormat (" {0}\n);", GetSource ("[" + procedure.OwnerName + "].[" + procedure.Name + "]"));
+ procedure.Definition = sb.ToString ();
+
+ // FIXME : get sysproc or not
+ procedures.Add (procedure);
+ } + r.Close ();
+ } + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return procedures;
+ }
+
+ public override ConstraintSchemaCollection GetTableConstraints (TableSchema table)
+ {
+ ConstraintSchemaCollection constraints = new ConstraintSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand ("select name, xtype from sysobjects where xtype in ('F','PK','CK')"); //TODO: unique + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) { + ConstraintSchema constraint = null; + switch (r.GetString (1)) { + case "F": //foreign key + constraint = new ForeignKeyConstraintSchema (this); + break; + case "PK": //primary key + constraint = new PrimaryKeyConstraintSchema (this); + break; + case "CK": //check constraint + constraint = new CheckConstraintSchema (this); + break; + default: + break; + }
+ + if (constraint != null) { + constraint.Name = r.GetString (0);
+ constraints.Add (constraint); + }
+ } + r.Close ();
+ } + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return constraints;
+ }
+
+ // see:
+ // http://www.firebirdsql.org/manual/migration-mssql-data-types.html
+ // http://webcoder.info/reference/MSSQLDataTypes.html
+ // http://www.tar.hu/sqlbible/sqlbible0022.html
+ // http://msdn2.microsoft.com/en-us/library/aa258876(SQL.80).aspx
+ public override DataTypeSchema GetDataType (string name)
+ {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+ name = name.ToLower ();
+
+ DataTypeSchema dts = new DataTypeSchema (this);
+ dts.Name = name;
+ switch (name) {
+ case "bigint":
+ dts.LengthRange = new Range (8);
+ dts.PrecisionRange = new Range (1, 19);
+ dts.DataTypeCategory = DataTypeCategory.Integer;
+ break;
+ case "binary":
+ dts.LengthRange = new Range (1, 8004);
+ dts.PrecisionRange = new Range (1, 8000);
+ dts.DataTypeCategory = DataTypeCategory.Binary;
+ break;
+ case "bit":
+ dts.LengthRange = new Range (1);
+ dts.DataTypeCategory = DataTypeCategory.Bit;
+ break;
+ case "char":
+ dts.LengthRange = new Range (1, 8000);
+ dts.PrecisionRange = new Range (1, 8000);
+ dts.DataTypeCategory = DataTypeCategory.Char;
+ break;
+ case "datetime":
+ dts.LengthRange = new Range (8);
+ dts.DataTypeCategory = DataTypeCategory.DateTime;
+ break;
+ case "decimal":
+ dts.LengthRange = new Range (5, 17);
+ dts.PrecisionRange = new Range (1, 38);
+ dts.ScaleRange = new Range (0, 37);
+ dts.DataTypeCategory = DataTypeCategory.Float;
+ break;
+ case "float":
+ dts.LengthRange = new Range (8);
+ dts.ScaleRange = new Range (1, 15);
+ dts.DataTypeCategory = DataTypeCategory.Float;
+ break;
+ case "image":
+ dts.LengthRange = new Range (0, int.MaxValue);
+ dts.PrecisionRange = new Range (0, int.MaxValue);
+ dts.DataTypeCategory = DataTypeCategory.VarBinary;
+ break;
+ case "int":
+ dts.LengthRange = new Range (4);
+ dts.PrecisionRange = new Range (1, 10);
+ dts.DataTypeCategory = DataTypeCategory.Integer;
+ break;
+ case "money":
+ dts.LengthRange = new Range (8);
+ dts.PrecisionRange = new Range (1, 19);
+ dts.ScaleRange = new Range (4);
+ dts.DataTypeCategory = DataTypeCategory.Integer;
+ break;
+ case "nchar":
+ dts.LengthRange = new Range (2, 8000);
+ dts.PrecisionRange = new Range (1, 4000);
+ dts.DataTypeCategory = DataTypeCategory.NChar;
+ break;
+ case "ntext":
+ dts.LengthRange = new Range (0, int.MaxValue);
+ dts.PrecisionRange = new Range (0, 1073741823);
+ dts.DataTypeCategory = DataTypeCategory.NVarChar;
+ break;
+ case "numeric":
+ dts.LengthRange = new Range (5, 17);
+ dts.PrecisionRange = new Range (1, 38);
+ dts.ScaleRange = new Range (0, 37);
+ dts.DataTypeCategory = DataTypeCategory.Float;
+ break;
+ case "nvarchar":
+ dts.LengthRange = new Range (0, 8000);
+ dts.PrecisionRange = new Range (0, 4000);
+ dts.DataTypeCategory = DataTypeCategory.NVarChar;
+ break;
+ case "real":
+ dts.LengthRange = new Range (4);
+ dts.ScaleRange = new Range (7);
+ dts.DataTypeCategory = DataTypeCategory.Float;
+ break;
+ case "smalldatetime":
+ dts.LengthRange = new Range (4);
+ dts.DataTypeCategory = DataTypeCategory.DateTime;
+ break;
+ case "smallint":
+ dts.LengthRange = new Range (2);
+ dts.PrecisionRange = new Range (5);
+ dts.DataTypeCategory = DataTypeCategory.Integer;
+ break;
+ case "smallmoney":
+ dts.LengthRange = new Range (4);
+ dts.PrecisionRange = new Range (10);
+ dts.ScaleRange = new Range (4);
+ dts.DataTypeCategory = DataTypeCategory.Integer;
+ break;
+ case "text":
+ dts.LengthRange = new Range (0, int.MaxValue);
+ dts.PrecisionRange = new Range (0, int.MaxValue);
+ dts.DataTypeCategory = DataTypeCategory.VarChar;
+ break;
+ case "timestamp":
+ dts.LengthRange = new Range (1, 8);
+ dts.DataTypeCategory = DataTypeCategory.TimeStamp;
+ break;
+ case "tinyint":
+ dts.LengthRange = new Range (1);
+ dts.PrecisionRange = new Range (1, 3);
+ dts.DataTypeCategory = DataTypeCategory.Integer;
+ break;
+ case "varbinary":
+ dts.LengthRange = new Range (1, 8004);
+ dts.PrecisionRange = new Range (0, 8000);
+ dts.DataTypeCategory = DataTypeCategory.VarBinary;
+ break;
+ case "varchar":
+ dts.LengthRange = new Range (1, 8000);
+ dts.PrecisionRange = new Range (0, 8000);
+ dts.DataTypeCategory = DataTypeCategory.VarChar;
+ break;
+ case "uniqueidentifier":
+ dts.LengthRange = new Range (16);
+ dts.DataTypeCategory = DataTypeCategory.Uid;
+ break;
+ case "xml":
+ dts.LengthRange = new Range (0, int.MaxValue);
+ dts.PrecisionRange = new Range (0, int.MaxValue);
+ dts.DataTypeCategory = DataTypeCategory.VarChar;
+ break;
+ case "cursor":
+ case "table":
+ case "sql_variant":
+ dts.DataTypeCategory = DataTypeCategory.Other;
+ break;
+ default:
+ break;
+ }
+
+ return dts;
+ } + + //http://msdn2.microsoft.com/en-us/library/aa258257(SQL.80).aspx + public override void CreateDatabase (DatabaseSchema database) + { + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand ("CREATE DATABASE " + database.Name); + try {
+ using (command)
+ command.ExecuteNonQuery (); + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release (); + } + + //http://msdn2.microsoft.com/en-us/library/aa258255(SQL.80).aspx + public override string GetTableCreateStatement (TableSchema table) + { + StringBuilder sb = new StringBuilder (); + sb.Append ("CREATE TABLE "); + sb.Append (table.Name); + sb.Append (" ("); + + bool first = true; + foreach (ColumnSchema column in table.Columns) { + if (first) + first = false; + else + sb.Append ("," + Environment.NewLine); + + sb.Append (column.Name); + sb.Append (' '); + sb.Append (column.DataType.GetCreateString (column)); + + if (column.HasDefaultValue) { + sb.Append (" DEFAULT "); + if (column.DefaultValue == null) + sb.Append ("NULL"); + else + sb.Append (column.DefaultValue); + } + if (!column.IsNullable) + sb.Append (" NOT NULL"); + //TODO: AUTO_INCREMENT + + foreach (ConstraintSchema constraint in column.Constraints) { + switch (constraint.ConstraintType) { + case ConstraintType.Unique: + sb.Append (" UNIQUE"); + break; + case ConstraintType.PrimaryKey: + sb.Append (" PRIMARY KEY"); + break; + default: + throw new NotImplementedException (); + } + } + + //TODO: col comment + } + //TODO: table comment + + foreach (ConstraintSchema constraint in table.Constraints) { + sb.Append ("," + Environment.NewLine); + sb.Append (GetConstraintString (constraint)); + } + + sb.Append (");"); + + foreach (TriggerSchema trigger in table.Triggers) { + sb.Append (Environment.NewLine); + sb.Append (GetTriggerCreateStatement (trigger)); + } + + return sb.ToString (); + } + + protected virtual string GetConstraintString (ConstraintSchema constraint) + { + StringBuilder sb = new StringBuilder (); + sb.Append ("CONSTRAINT "); + sb.Append (constraint.Name); + sb.Append (' '); + + switch (constraint.ConstraintType) { + case ConstraintType.PrimaryKey: + sb.Append ("PRIMARY KEY "); + sb.Append (GetColumnsString (constraint.Columns, true)); + break; + case ConstraintType.Unique: + sb.Append ("UNIQUE "); + sb.Append (GetColumnsString (constraint.Columns, true)); + break; + case ConstraintType.Check: + sb.Append ("CHECK ("); + sb.Append ((constraint as CheckConstraintSchema).Source); + sb.Append (")"); + break; + case ConstraintType.ForeignKey: + sb.Append ("FOREIGN KEY "); + sb.Append (GetColumnsString (constraint.Columns, true)); + sb.Append (" REFERENCES "); + + ForeignKeyConstraintSchema fk = constraint as ForeignKeyConstraintSchema; + sb.Append (fk.ReferenceTable); + sb.Append (' '); + if (fk.ReferenceColumns != null) + sb.Append (GetColumnsString (fk.ReferenceColumns, true)); + break; + default: + throw new NotImplementedException (); + } + + return sb.ToString (); + } + + //http://msdn2.microsoft.com/en-us/library/aa258254(SQL.80).aspx + public override void CreateView (ViewSchema view) + { + throw new NotImplementedException (); + } + + //http://msdn2.microsoft.com/en-us/library/aa258259(SQL.80).aspx + public override void CreateProcedure (ProcedureSchema procedure) + { + throw new NotImplementedException (); + } + + //http://msdn2.microsoft.com/en-us/library/aa258259(SQL.80).aspx + public override void CreateIndex (IndexSchema index) + { + throw new NotImplementedException (); + } + + //http://msdn2.microsoft.com/en-us/library/aa258254(SQL.80).aspx + public override void CreateTrigger (TriggerSchema trigger) + { + string sql = GetTriggerCreateStatement (trigger); + ExecuteNonQuery (sql); + } + + protected virtual string GetTriggerCreateStatement (TriggerSchema trigger) + { + StringBuilder sb = new StringBuilder (); + +// { FOR | AFTER | INSTEAD OF } { [ INSERT ] [ , ] [ UPDATE ] [ , ] [ DELETE ] } +// [ WITH APPEND ] +// [ NOT FOR REPLICATION ] +// AS +// [ { IF UPDATE ( column ) +// [ { AND | OR } UPDATE ( column ) ] +// [ ...n ] +// | IF ( COLUMNS_UPDATED ( ) { bitwise_operator } updated_bitmask ) +// { comparison_operator } column_bitmask [ ...n ] +// } ] +// sql_statement [ ...n ] + + sb.Append ("CREATE TRIGGER "); + sb.Append (trigger.Name); + sb.Append (" ON "); + sb.Append (trigger.TableName); + + if (trigger.TriggerType == TriggerType.Before) + sb.Append (" FOR "); + else + sb.Append (" AFTER "); + + switch (trigger.TriggerEvent) { + case TriggerEvent.Delete: + sb.Append ("DELETE"); + break; + case TriggerEvent.Insert: + sb.Append ("INSERT"); + break; + case TriggerEvent.Update: + sb.Append ("UPDATE"); + break; + default: + throw new NotImplementedException (); + } + + sb.Append (" AS "); + sb.Append (Environment.NewLine); + sb.Append (trigger.Source); + sb.Append (";"); + + return sb.ToString (); + } + + //http://msdn2.microsoft.com/en-us/library/aa275464(SQL.80).aspx + public override void AlterDatabase (DatabaseSchema database) + { + throw new NotImplementedException (); + } + + //http://msdn2.microsoft.com/en-us/library/aa225939(SQL.80).aspx + public override void AlterTable (TableSchema table) + { + throw new NotImplementedException (); + } + + //http://msdn2.microsoft.com/en-us/library/aa225939(SQL.80).aspx + public override void AlterView (ViewSchema view) + { + ExecuteNonQuery (view.Definition); + } + + //http://msdn2.microsoft.com/en-us/library/aa225939(SQL.80).aspx + public override void AlterProcedure (ProcedureSchema procedure) + { + ExecuteNonQuery (procedure.Definition); + } + + public override void AlterIndex (IndexSchema index) + { + throw new NotImplementedException (); + } + + //http://msdn2.microsoft.com/en-us/library/aa225939(SQL.80).aspx + public override void AlterTrigger (TriggerSchema trigger) + { + throw new NotImplementedException (); + } + + public override void AlterUser (UserSchema user) + { + throw new NotImplementedException (); + } + + //http://msdn2.microsoft.com/en-us/library/aa258843(SQL.80).aspx + public override void DropDatabase (DatabaseSchema database) + { + ExecuteNonQuery ("DROP DATABASE " + database.Name); + } + + //http://msdn2.microsoft.com/en-us/library/aa258841(SQL.80).aspx + public override void DropTable (TableSchema table) + { + ExecuteNonQuery ("DROP TABLE " + table.Name); + } + + //http://msdn2.microsoft.com/en-us/library/aa258835(SQL.80).aspx + public override void DropView (ViewSchema view) + { + ExecuteNonQuery ("DROP VIEW " + view.Name); + } + + //http://msdn2.microsoft.com/en-us/library/aa258830(SQL.80).aspx + public override void DropProcedure (ProcedureSchema procedure) + { + ExecuteNonQuery ("DROP PROCEDURE " + procedure.Name); + } + + //http://msdn2.microsoft.com/en-us/library/aa225939(SQL.80).aspx + public override void DropIndex (IndexSchema index) + { + ExecuteNonQuery ("DROP INDEX '" + index.TableName + "." + index.Name + "'"); + } + + //http://msdn2.microsoft.com/en-us/library/aa258846(SQL.80).aspx + public override void DropTrigger (TriggerSchema trigger) + { + ExecuteNonQuery ("DROP TRIGGER " + trigger.Name); + } + + //http://msdn2.microsoft.com/en-US/library/aa238878(SQL.80).aspx + public override void RenameDatabase (DatabaseSchema database, string name) + { + Rename (database.Name, name, "DATABASE"); + + database.Name = name; + connectionPool.ConnectionContext.ConnectionSettings.Database = name; + } + + //http://msdn2.microsoft.com/en-US/library/aa238878(SQL.80).aspx + public override void RenameTable (TableSchema table, string name) + { + Rename (table.Name, name, "OBJECT"); + table.Name = name; + } + + //http://msdn2.microsoft.com/en-US/library/aa238878(SQL.80).aspx + public override void RenameView (ViewSchema view, string name) + { + Rename (view.Name, name, "OBJECT"); + view.Name = name; + } + + //http://msdn2.microsoft.com/en-US/library/aa238878(SQL.80).aspx + public override void RenameProcedure (ProcedureSchema procedure, string name) + { + Rename (procedure.Name, name, "OBJECT"); + procedure.Name = name; + } + + //http://msdn2.microsoft.com/en-US/library/aa238878(SQL.80).aspx + public override void RenameIndex (IndexSchema index, string name) + { + Rename (index.Name, name, "INDEX"); + index.Name = name; + } + + //http://msdn2.microsoft.com/en-US/library/aa238878(SQL.80).aspx + public override void RenameTrigger (TriggerSchema trigger, string name) + { + Rename (trigger.Name, name, "OBJECT"); + trigger.Name = name; + } + + public override string GetViewAlterStatement (ViewSchema view) + { + return String.Concat ("DROP VIEW ", view.Name, "; ", Environment.NewLine, view.Definition); + } + + public override string GetProcedureAlterStatement (ProcedureSchema procedure) + { + return String.Concat ("DROP PROCEDURE ", procedure.Name, "; ", Environment.NewLine, procedure.Definition); + }
+
+ protected string GetTableDefinition (TableSchema table)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.AppendFormat ("-- Table: {0}\n", table.Name);
+ sb.AppendFormat ("-- DROP TABLE {0};\n\n", table.Name);
+ sb.AppendFormat ("CREATE TABLE {0} (\n", table.Name);
+
+ ColumnSchemaCollection columns = table.Columns;
+ string[] parts = new string[columns.Count];
+ int i = 0;
+ foreach (ColumnSchema col in columns)
+ parts[i++] = col.Definition;
+ sb.Append (String.Join (",\n", parts));
+
+ ConstraintSchemaCollection constraints = table.Constraints;
+ parts = new string[constraints.Count];
+ if (constraints.Count > 0)
+ sb.Append (",\n");
+ i = 0;
+ foreach (ConstraintSchema constr in constraints)
+ parts[i++] = "\t" + constr.Definition;
+ sb.Append (String.Join (",\n", parts));
+
+ sb.Append ("\n);\n");
+ //sb.AppendFormat ("COMMENT ON TABLE {0} IS '{1}';", table.Name, table.Comment);
+ return sb.ToString ();
+ }
+
+ private string GetSource (string objectName)
+ { + LoggingService.LogDebug ("GetSource: " + objectName); + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand (
+ String.Format ("EXEC sp_helptext '{0}', null", objectName)
+ ); + StringBuilder sb = new StringBuilder (); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ())
+ sb.Append (r.GetString (0)); + r.Close (); + } + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return sb.ToString ();
+ } + + //http://msdn2.microsoft.com/en-US/library/aa238878(SQL.80).aspx + private void Rename (string oldName, string newName, string type)
+ { + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateStoredProcedure (
+ String.Format ("EXEC sp_rename '{0}', '{1}', '{2}'", oldName, newName, type)
+ ); + try {
+ using (command)
+ command.ExecuteNonQuery (); + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+ }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/AssemblyInfo.cs.in b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/AssemblyInfo.cs.in new file mode 100644 index 0000000000..e867b8e906 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/AssemblyInfo.cs.in @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("MonoDevelop.Database.Sql.Odbc")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("http://www.monodevelop.com")] +[assembly: AssemblyCopyright("MIT X11 - Christian Hergert, Ankit Jain, Ben Motmans")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: AssemblyVersion("@ASSEMBLY_VERSION@")] + +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/ChangeLog b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/ChangeLog new file mode 100644 index 0000000000..f6182fafaa --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/ChangeLog @@ -0,0 +1,128 @@ +2007-11-09 Michael Hutchinson <mhutchinson@novell.com> + + * SqliteSchemaProvider.cs: Track LoggingService API. Replace some "LogError" + calls with "LogDebug" calls. + +2007-10-29 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Sqlite.addin.xml: Bump MD version. + +2007-10-23 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Sqlite.mdp: Project file names updated by change + in MD path functions. + +2007-10-16 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Sqlite.mdp: Fix required GTK# version. + +2007-09-26 Michael Hutchinson <mhutchinson@novell.com> + + * MonoDevelop.Database.Sql.Sqlite.mdp: Don't unnecessarily local-copy + project references. Don't sync EXTRA_DIST with deploy files. Add + Makefile.am to file list. + * Makefile.am: Don't deploy .addin.xml file. + +2007-09-21 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Sqlite.addin.xml: Bump MD version. + +2007-09-20 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: removed incorrect references + +2007-09-20 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: changed reference to contrib/Sqlite + +2007-09-19 Ben Motmans <ben.motmans@gmail.com> + + * MonoDevelop.Database.Sql.Sqlite.addin.xml: temporarily disabled the Create + table command due to a bug in the database provider + +2007-09-16 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: link to the correct Mono.Addins dll + +2007-09-07 Ben Motmans <ben.motmans@gmail.com> + + * SqliteSchemaProvider.cs, SqliteDbFactory.cs, + MonoDevelop.Database.Sql.Sqlite.addin.xml: improved capabilities system + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * MonoDevelop.Database.Sql.Sqlite.mdp, Makefile.am: use project references + instead of assembly references + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: updated makefile + +2007-08-03 Ben Motmans <ben.motmans@gmail.com> + + * SqliteConnectionProvider.cs: added support for an error message + * SqliteSchemaProvider.cs: fixed a bug in the CreateTable method + +2007-08-02 Ben Motmans <ben.motmans@gmail.com> + + * SqliteSchemaProvider.cs: CreateTrigger implementation + +2007-08-01 Ben Motmans <ben.motmans@gmail.com> + + * SqliteSchemaProvider.cs: Catch exceptions and notify the user and various + small bugfixes + +2007-07-31 Ben Motmans <ben.motmans@gmail.com> + + * SqliteDbFactory.cs, SqliteGuiProvider.cs: Added a GuiProvider + * SqliteSchemaProvider.cs: small api changes + +2007-07-25 Ben Motmans <ben.motmans@gmail.com> + + * SqliteDbFactory.cs: Added support for a save database dialog + * SqliteConnectionProvider.cs, SqlitePooledDbConnection.cs: moved from + Mono.Data.SqliteClient to Mono.Data.Sqlite + * SqliteSchemaProvider.cs: added meta data information, support for GetDataTypes, + CreateTable, DropDatabase and CreateDatabase + +2007-07-18 Ben Motmans <ben.motmans@gmail.com> + + * SqliteSchemaProvider.cs: SupportsSchemaOperation implementation, use of strongly typed + collections, Drop* and Rename* implementations + +2007-07-17 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: initial makefile + * SqliteDbFactory.cs: implemented methods required for the connection settings dialog + +2007-07-15 Ben Motmans <ben.motmans@gmail.com> + + * SqliteDialect.cs: dialect implementation with keyword detection + * SqliteDbFactory.cs: use SqliteDialect instead of the obsolete Sql99Dialect + +2007-07-14 Ben Motmans <ben.motmans@gmail.com> + + * SqliteConnectionProvider.cs, SqliteDbFactory.cs, SqliteSchemaProvider.cs: small changes + to reflect API changes + * SqlitePooledDbConnection.cs: implementation of ConnectionPool aware connection + +2007-07-10 Ben Motmans <ben.motmans@gmail.com> + + * SqliteConnectionProvider.cs: set IsConnectionError property + +2007-07-05 Ben Motmans <ben.motmans@gmail.com> + + * SqliteConnectionProvider.cs: ExecuteQueryAsDataSet and ExecuteQueryAsDataTable implementation + * SqliteDbFactory.cs: specified the ISqlDialect and added default connection settings + +2007-07-02 Ben Motmans <ben.motmans@gmail.com> + + * SqliteSchemaProvider.cs: + Imported the old DbProvider and updated all to code to use the new API + +2007-07-01 Ben Motmans <ben.motmans@gmail.com> + + * SqliteSchemaProvider.cs: + * SqliteDbFactory.cs: + * SqliteConnectionProvider.cs: + Imported original code and splitted in 3 classes diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/Makefile.am b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/Makefile.am new file mode 100644 index 0000000000..cbeb64d0c3 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/Makefile.am @@ -0,0 +1,52 @@ +ADDIN_BUILD = $(top_builddir)/build/AddIns/MonoDevelop.Database +ASSEMBLY = $(ADDIN_BUILD)/MonoDevelop.Database.Sql.Sqlite.dll +REFS = \ + $(GTK_SHARP_LIBS) \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Components.dll \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Designer.dll \ + -r:$(top_builddir)/build/AddIns/MonoDevelop.Database/MonoDevelop.Database.Sql.dll \ + -r:$(top_builddir)/build/bin/Mono.Addins.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Components.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.Gui.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Ide.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Projects.dll \ + -r:$(top_srcdir)/contrib/Sqlite/Mono.Data.Sqlite.dll \ + -r:Mono.Data \ + -r:System \ + -r:System.Data + +FILES = \ + SqliteConnectionProvider.cs \ + SqliteDbFactory.cs \ + SqliteDialect.cs \ + SqliteGuiProvider.cs \ + SqlitePooledDbConnection.cs \ + SqliteSchemaProvider.cs + +RES = MonoDevelop.Database.Sql.Sqlite.addin.xml + +SQLITE_FILES = \ + Mono.Data.Sqlite.dll + +SRC_SQLITE_FILES = $(addprefix $(top_srcdir)/contrib/Sqlite/, $(SQLITE_FILES)) +BUILD_SQLITE_FILES = $(addprefix $(ADDIN_BUILD)/, $(notdir $(SQLITE_FILES))) + +all: $(ASSEMBLY) $(BUILD_SQLITE_FILES) + +$(BUILD_SQLITE_FILES): $(SRC_SQLITE_FILES) + mkdir -p $(ADDIN_BUILD) + cp $(SRC_SQLITE_FILES) $(ADDIN_BUILD)/. + +$(ASSEMBLY): $(FILES) $(build_resources) + mkdir -p $(ADDIN_BUILD) + $(CSC) $(CSC_FLAGS) $(REFS) $(build_resources:%=/resource:%) $(build_sources) -out:$@ -target:library + + +assemblydir = $(MD_ADDIN_DIR)/MonoDevelop.Database +assembly_DATA = $(ASSEMBLY) $(BUILD_SQLITE_FILES) + +CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb $(BUILD_SQLITE_FILES) +EXTRA_DIST = $(FILES) $(RES) $(SRC_SQLITE_FILES) + +include $(top_srcdir)/Makefile.include diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/MonoDevelop.Database.Sql.Sqlite.addin.xml b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/MonoDevelop.Database.Sql.Sqlite.addin.xml new file mode 100644 index 0000000000..da79008542 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/MonoDevelop.Database.Sql.Sqlite.addin.xml @@ -0,0 +1,56 @@ +<Addin id = "Database.Sql.Sqlite" + namespace = "MonoDevelop" + name = "Sqlite provider for Mono Data Sql" + author = "Christian Hergert, Ankit Jain, Ben Motmans" + copyright = "MIT X11" + url = "http://www.monodevelop.com" + description = "Database Module" + version = "0.17.0"> + + <Runtime> + <Import assembly="MonoDevelop.Database.Sql.Sqlite.dll"/> + </Runtime> + + <Dependencies> + <Addin id="Core" version="0.17.0"/> + <Addin id="Core.Gui" version="0.17.0"/> + <Addin id="Ide" version="0.17.0"/> + <Addin id="Database.Sql" version="0.17.0"/> + <Addin id="Database.Components" version="0.17.0"/> + <Addin id="Database.Designer" version="0.17.0"/> + </Dependencies> + + <Extension path = "/MonoDevelop/Database/Sql"> + <DatabaseFactory id = "Sqlite" class = "MonoDevelop.Database.Sql.SqliteDbFactory"> + <!-- action flags --> + <Actions category="Database" flags="Create,Drop,Schema" /> + <Actions category="Table" flags="Drop,Rename,Schema" /> + <Actions category="View" flags="Create,Drop,Schema" /> + <Actions category="TableColumn" flags="All" /> + <Actions category="Parameter" flags="Schema" /> + <Actions category="Trigger" flags="All" /> + <Actions category="PrimaryKeyConstraint" flags="Create,Schema" /> + <Actions category="CheckConstraint" flags="Create,Schema" /> + <Actions category="UniqueConstraint" flags="Create,Schema" /> + + <!-- ConnectionSettings capabilities --> + <Capabilities category="ConnectionSettings" action="Schema" flags="SelectDatabase" /> + <!-- table capabilities --> + <Capabilities category="Table" action="All" flags="Name,Definition,Schema,IsSystem,Columns,PrimaryKeyConstraint,CheckConstraint,UniqueConstraint" /> + <Capabilities category="Table" action="Alter" flags="AppendConstraint,InsertConstraint,RemoveConstraint,AppendTrigger,InsertTrigger,RemoveTrigger,AppendColumn" /> + <!-- Table Column capabilities --> + <Capabilities category="TableColumn" action="All" flags="Name,Definition,Schema,DataType,DefaultValue,Nullable,Position,PrimaryKeyConstraint,CheckConstraint,UniqueConstraint" /> + <Capabilities category="TableColumn" action="Alter" flags="AppendConstraint,InsertConstraint,RemoveConstraint" /> + <!-- View capabilities --> + <Capabilities category="View" action="All" flags="Name,Definition,Schema,Statement,IsSystem" /> + <!-- Trigger capabilities --> + <Capabilities category="Trigger" action="All" flags="Name,Schema,TableName,TriggerType,TriggerEvent,TriggerFireType,Position,IsActive,Source" /> + <!-- PrimaryKeyConstraint capabilities --> + <Capabilities category="PrimaryKeyConstraint" action="All" flags="Name,Columns,IsColumnConstraint" /> + <!-- CheckConstraint capabilities --> + <Capabilities category="CheckConstraint" action="All" flags="Name,Columns,IsColumnConstraint,Source" /> + <!-- UniqueConstraint capabilities --> + <Capabilities category="UniqueConstraint" action="All" flags="Name,Columns,IsColumnConstraint" /> + </DatabaseFactory> + </Extension> +</Addin> diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/MonoDevelop.Database.Sql.Sqlite.mdp b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/MonoDevelop.Database.Sql.Sqlite.mdp new file mode 100644 index 0000000000..2e233b9097 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/MonoDevelop.Database.Sql.Sqlite.mdp @@ -0,0 +1,54 @@ +<Project name="MonoDevelop.Database.Sql.Sqlite" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql.Sqlite" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql.Sqlite" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="SqliteConnectionProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="SqliteSchemaProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="MonoDevelop.Database.Sql.Sqlite.addin.xml" subtype="Code" buildaction="EmbedAsResource" /> + <File name="SqliteDbFactory.cs" subtype="Code" buildaction="Compile" /> + <File name="SqlitePooledDbConnection.cs" subtype="Code" buildaction="Compile" /> + <File name="SqliteDialect.cs" subtype="Code" buildaction="Compile" /> + <File name="SqliteGuiProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="Makefile.am" subtype="Code" buildaction="Nothing" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="Mono.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Designer" /> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Sql" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Ide" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core.Gui" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Components" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Projects" /> + <ProjectReference type="Project" localcopy="False" refto="Mono.Addins" /> + <ProjectReference type="Assembly" localcopy="True" refto="../../../contrib/Sqlite/Mono.Data.Sqlite.dll" /> + <ProjectReference type="Gac" localcopy="True" refto="pango-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="atk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <ProjectReference type="Project" localcopy="True" refto="MonoDevelop.Database.Components" /> + </References> + <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am" BuildTargetName="" CleanTargetName="" SyncReferences="True" IsAutotoolsProject="True" RelativeConfigureInPath="../../../"> + <BuildFilesVar Sync="True" Name="FILES" /> + <DeployFilesVar /> + <ResourcesVar Sync="True" Name="RES" /> + <OthersVar /> + <GacRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <AsmRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <ProjectRefVar Sync="True" Name="REFS" Prefix="-r:" /> + </MonoDevelop.Autotools.MakefileInfo> +</Project>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqliteConnectionProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqliteConnectionProvider.cs new file mode 100644 index 0000000000..9ba11abed4 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqliteConnectionProvider.cs @@ -0,0 +1,58 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ankit Jain <radical@corewars.org> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic; +using Mono.Data.Sqlite;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class SqliteConnectionProvider : AbstractConnectionProvider
+ {
+ public override IPooledDbConnection CreateConnection (IConnectionPool pool, DatabaseConnectionSettings settings, out string error)
+ { + string connStr = null;
+ try {
+ if (settings.UseConnectionString) {
+ connStr = settings.ConnectionString;
+ } else {
+ connStr = String.Concat ("URI=file:", settings.Database);
+ }
+ SqliteConnection connection = new SqliteConnection (connStr);
+ connection.Open ();
+ + error = null;
+ return new SqlitePooledDbConnection (pool, connection);
+ } catch (Exception e) { + error = e.Message;
+ return null;
+ }
+ }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqliteDbFactory.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqliteDbFactory.cs new file mode 100644 index 0000000000..293b004be3 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqliteDbFactory.cs @@ -0,0 +1,92 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+ +using System;
+using System.Data;
+using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; +using MonoDevelop.Database.Components; +using MonoDevelop.Ide.Gui.Dialogs;
+
namespace MonoDevelop.Database.Sql
+{
+ public class SqliteDbFactory : AbstractDbFactory
+ { + private ISqlDialect dialect; + private IConnectionProvider connectionProvider; + private IGuiProvider guiProvider; + + public override string Identifier { + get { return "Mono.Data.Sqlite"; } + } +
+ public override string Name { + get { return "SQLite database"; } + } + + public override ISqlDialect Dialect { + get { + if (dialect == null) + dialect = new SqliteDialect (); + return dialect; + } + } + + public override IConnectionProvider ConnectionProvider { + get { + if (connectionProvider == null) + connectionProvider = new SqliteConnectionProvider (); + return connectionProvider; + } + } + + public override IGuiProvider GuiProvider { + get { + if (guiProvider == null) + guiProvider = new SqliteGuiProvider (); + return guiProvider; + } + } + + public override IConnectionPool CreateConnectionPool (DatabaseConnectionContext context) + { + return new DefaultConnectionPool (this, ConnectionProvider, context); + } + + public override ISchemaProvider CreateSchemaProvider (IConnectionPool connectionPool) + { + return new SqliteSchemaProvider (connectionPool); + } + + public override DatabaseConnectionSettings GetDefaultConnectionSettings () + { + DatabaseConnectionSettings settings = new DatabaseConnectionSettings (); + settings.ProviderIdentifier = Identifier; + settings.MaxPoolSize = 5; + + return settings; + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqliteDialect.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqliteDialect.cs new file mode 100644 index 0000000000..6bb2735f0c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqliteDialect.cs @@ -0,0 +1,85 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic; +
namespace MonoDevelop.Database.Sql
+{
+ public class SqliteDialect : AbstractSqlDialect
+ { + public override string QuoteIdentifier (string identifier) + { + if (identifier == null) + throw new ArgumentNullException ("identifier"); + + if (IsReservedWord (identifier) || identifier.Contains (" ")) + return String.Concat ('"', identifier, '"'); + + return identifier; + } + + public override string MarkAsParameter (string identifier) + { + if (identifier == null) + throw new ArgumentNullException ("identifier"); + + return ":" + identifier; + } + + //http://www.sqlite.org/lang_keywords.html + protected virtual bool IsReservedWord (string word) + { + word = word.ToUpper (); + + switch (word) { + case "CREATE": case "FOREIGN": case "LIMIT": + case "ROLLBACK": case "ADD": case "CROSS": + case "FROM": case "FULL": case "NATURAL": + case "SELECT": case "ALL": case "NOT": + case "SET": case "ALTER": case "GROUP": + case "NOTNULL": case "TABLE": case "HAVING": + case "NULL": case "AND": case "DEFAULT": + case "AS": case "DEFERRABLE": case "THEN": + case "ON": case "TO": case "DELETE": + case "IN": case "OR": case "TRANSACTION": + case "INDEX": case "ORDER": case "AUTOINCREMENT": + case "OUTER": case "UNION": case "DISTINCT": + case "INNER": case "UNIQUE": case "BETWEEN": + case "DROP": case "INSERT": case "UPDATE": + case "BY": case "PRIMARY": case "USING": + case "ELSE": case "INTERSECT": case "CASE": + case "INTO": case "ESCAPE": case "IS": + case "REFERENCES": case "CHECK": case "EXCEPT": + case "ISNULL": case "COLLATE": case "JOIN": + case "WHEN": case "WHERE": case "COMMIT": + case "LEFT": case "RIGHT": case "CONSTRAINT": + return true; + default: + return false; + } + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqliteGuiProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqliteGuiProvider.cs new file mode 100644 index 0000000000..8109c100ac --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqliteGuiProvider.cs @@ -0,0 +1,111 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using Gtk; +using System;
+using System.Data;
+using System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Database.Designer; +using MonoDevelop.Database.Components;
+
namespace MonoDevelop.Database.Sql
+{
+ public class SqliteGuiProvider : IGuiProvider
+ { + public bool ShowSelectDatabaseDialog (bool create, out string database) + { + FileChooserDialog dlg = null; + if (create) { + dlg = new FileChooserDialog ( + GettextCatalog.GetString ("Save Database"), null, FileChooserAction.Save, + "gtk-cancel", ResponseType.Cancel, + "gtk-save", ResponseType.Accept + ); + } else { + dlg = new FileChooserDialog ( + GettextCatalog.GetString ("Open Database"), null, FileChooserAction.Open, + "gtk-cancel", ResponseType.Cancel, + "gtk-open", ResponseType.Accept + ); + } + dlg.SelectMultiple = false; + dlg.LocalOnly = true; + dlg.Modal = true; + + FileFilter filter = new FileFilter (); + filter.AddMimeType ("application/x-sqlite2"); + filter.AddMimeType ("application/x-sqlite3"); + filter.AddPattern ("*.db"); + filter.Name = GettextCatalog.GetString ("SQLite databases"); + FileFilter filterAll = new FileFilter (); + filterAll.AddPattern ("*"); + filterAll.Name = GettextCatalog.GetString ("All files"); + dlg.AddFilter (filter); + dlg.AddFilter (filterAll); + + if (dlg.Run () == (int)ResponseType.Accept) { + database = dlg.Filename; + dlg.Destroy (); + return true; + } else { + dlg.Destroy (); + database = null; + return false; + } + } + + public bool ShowTableEditorDialog (ISchemaProvider schemaProvider, TableSchema table, bool create) + { + return RunDialog (new TableEditorDialog (schemaProvider, table, create)); + } + + public bool ShowViewEditorDialog (ISchemaProvider schemaProvider, ViewSchema view, bool create) + { + return RunDialog (new ViewEditorDialog (schemaProvider, view, create)); + } + + public bool ShowProcedureEditorDialog (ISchemaProvider schemaProvider, ProcedureSchema procedure, bool create) + { + return RunDialog (new ProcedureEditorDialog (schemaProvider, procedure, create)); + } + + public bool ShowUserEditorDialog (ISchemaProvider schemaProvider, UserSchema user, bool create) + { + return RunDialog (new UserEditorDialog (schemaProvider, user, create)); + } + + private bool RunDialog (Dialog dlg) + { + bool result = false; + try { + if (dlg.Run () == (int)ResponseType.Ok) + result = true; + } finally { + dlg.Destroy (); + } + return result; + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqlitePooledDbConnection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqlitePooledDbConnection.cs new file mode 100644 index 0000000000..799adc905b --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqlitePooledDbConnection.cs @@ -0,0 +1,81 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic; +using Mono.Data.Sqlite;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class SqlitePooledDbConnection : AbstractPooledDbConnection
+ { + public SqlitePooledDbConnection (IConnectionPool connectionPool, IDbConnection connection) + : base (connectionPool, connection) + { + } + + public override DataSet ExecuteSet (IDbCommand command) + { + if (command == null) + throw new ArgumentException ("command"); + + DataSet set = new DataSet (); + using (command) { + using (SqliteDataAdapter adapter = new SqliteDataAdapter (command as SqliteCommand)) { + try { + adapter.Fill (set); + } catch (Exception e) { + QueryService.RaiseException (e); + } + } + } + return set; + } + + public override DataTable ExecuteTable (IDbCommand command) + { + if (command == null) + throw new ArgumentException ("command"); + + DataTable table = new DataTable (); + using (command) { + using (SqliteDataAdapter adapter = new SqliteDataAdapter (command as SqliteCommand)) { + try { + adapter.Fill (table); + } catch (Exception e) { + QueryService.RaiseException (e); + } + } + } + return table; + } + + public override DataTable GetSchema (string collectionName, params string[] restrictionValues) + { + return (connection as SqliteConnection).GetSchema (collectionName, restrictionValues); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqliteSchemaProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqliteSchemaProvider.cs new file mode 100644 index 0000000000..6ed023635a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sqlite/SqliteSchemaProvider.cs @@ -0,0 +1,446 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ankit Jain <radical@corewars.org> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System; +using System.Text;
+using System.Data;
+using System.Collections.Generic; +using Mono.Data.Sqlite; +using MonoDevelop.Core;
+
+namespace MonoDevelop.Database.Sql
+{ + // see: http://www.sqlite.org/faq.html + // http://www.sqlite.org/google-talk-slides/page-021.html
+ public class SqliteSchemaProvider : AbstractSchemaProvider
+ {
+ public SqliteSchemaProvider (IConnectionPool connectionPool)
+ : base (connectionPool)
+ {
+ }
+
+ public override TableSchemaCollection GetTables ()
+ {
+ TableSchemaCollection tables = new TableSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand ( + "SELECT name, sql FROM sqlite_master WHERE type = 'table'" + ); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ TableSchema table = new TableSchema (this);
+ + table.SchemaName = "main";
+ table.Name = r.GetString (0); + table.IsSystemTable = table.Name.StartsWith ("sqlite_"); + table.Definition = r.GetString (1);
+
+ tables.Add (table);
+ } + r.Close ();
+ }
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return tables;
+ }
+
+ public override ColumnSchemaCollection GetTableColumns (TableSchema table)
+ {
+ ColumnSchemaCollection columns = new ColumnSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand ( + "PRAGMA table_info('" + table.Name + "')" + ); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ColumnSchema column = new ColumnSchema (this, table); +
+ column.Position = r.GetInt32 (0); + column.Name = r.GetString (1); + column.DataTypeName = r.GetString (2); + column.IsNullable = r.GetInt32 (3) != 0; + column.DefaultValue = r.IsDBNull (4) ? null : r.GetValue (4).ToString ();
+
+ columns.Add (column);
+ } + r.Close ();
+ };
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return columns;
+ } + + public override ViewSchemaCollection GetViews ()
+ {
+ ViewSchemaCollection views = new ViewSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request ();
+ IDbCommand command = conn.CreateCommand ( + "SELECT name, sql FROM sqlite_master WHERE type = 'views'" + ); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ViewSchema view = new ViewSchema (this);
+ + view.SchemaName = "main";
+ view.Name = r.GetString (0); + view.Definition = r.GetString (1);
+
+ views.Add (view);
+ } + r.Close ();
+ }
+ } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release ();
+
+ return views;
+ } + + public override ConstraintSchemaCollection GetTableConstraints (TableSchema table) + { + return GetConstraints (table, null); + } + + public override ConstraintSchemaCollection GetColumnConstraints (TableSchema table, ColumnSchema column) + { + return GetConstraints (table, column); + } + + //http://www.sqlite.org/pragma.html + public virtual ConstraintSchemaCollection GetConstraints (TableSchema table, ColumnSchema column)
+ { + if (table == null) + throw new ArgumentNullException ("table"); + string columnName = column == null ? null : column.Name; +
+ ConstraintSchemaCollection constraints = new ConstraintSchemaCollection ();
+ + IPooledDbConnection conn = connectionPool.Request (); + + //fk and unique
+ IDbCommand command = conn.CreateCommand ("SELECT name, tbl_name FROM sqlite_master WHERE sql IS NULL AND type = 'index'"); + try {
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ConstraintSchema constraint = null; + + if (r.IsDBNull (1) || r.GetString (1) == null) { + constraint = new UniqueConstraintSchema (this); + } else { + ForeignKeyConstraintSchema fkc = new ForeignKeyConstraintSchema (this); + fkc.ReferenceTableName = r.GetString (1); + + constraint = fkc; + } + constraint.Name = r.GetString (0);
+
+ constraints.Add (constraint);
+ } + r.Close ();
+ } + } + + //pk, column + if (columnName != null) { + command = conn.CreateCommand ( + "PRAGMA table_info('" + table.Name + "')" + );
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) { + if (r.GetInt32 (5) == 1 && r.GetString (1) == columnName) { + PrimaryKeyConstraintSchema constraint = new PrimaryKeyConstraintSchema (this); + + ColumnSchema priColumn = new ColumnSchema (this, table); + priColumn.Name = r.GetString (1); + + constraint.Columns.Add (priColumn); + constraint.IsColumnConstraint = true; + constraint.Name = "pk_" + table.Name + "_" + priColumn.Name; + + constraints.Add (constraint); + }
+ } + r.Close ();
+ }
+ } + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + + conn.Release ();
+
+ return constraints;
+ } + + public override void CreateDatabase (DatabaseSchema database) + { + //TODO: error if db exists + LoggingService.LogDebug ("CREATE START"); + + SqliteConnection conn = new SqliteConnection ("URI=file:" + database.Name + ";Version=3;"); + conn.Open (); + conn.Close (); + + LoggingService.LogDebug ("CREATE STOP"); + } + + //http://www.sqlite.org/lang_createtable.html + public override string GetTableCreateStatement (TableSchema table) + { + StringBuilder sb = new StringBuilder (); + + sb.Append ("CREATE TABLE "); + sb.Append (table.Name); + sb.Append (" ( "); + + bool first = true; + foreach (ColumnSchema column in table.Columns) { + if (first) + first = false; + else + sb.Append ("," + Environment.NewLine); + + sb.Append (column.Name); + sb.Append (' '); + sb.Append (column.DataType.GetCreateString (column)); + + if (!column.IsNullable) + sb.Append (" NOT NULL"); + if (column.HasDefaultValue) + sb.Append (" DEFAULT " + column.DefaultValue == null ? "NULL" : column.DefaultValue.ToString ()); //TODO: '' chars if string + + //list all column constrains for this type + foreach (ConstraintSchema constraint in column.Constraints) { + sb.Append (" "); + sb.Append (GetConstraintString (constraint)); + } + } + + //table constraints + foreach (ConstraintSchema constraint in table.Constraints) { + sb.Append (", "); + sb.Append (GetConstraintString (constraint)); + } + + sb.Append (" );"); + + foreach (TriggerSchema trigger in table.Triggers) { + sb.Append (Environment.NewLine); + sb.Append (GetTriggerCreateStatement (trigger)); + } + + return sb.ToString (); + } + + protected virtual string GetConstraintString (ConstraintSchema constraint) + { + //PRIMARY KEY [sort-order] [ conflict-clause ] [AUTOINCREMENT] + //UNIQUE [ conflict-clause ] + //CHECK ( expr ) + //COLLATE collation-name + + StringBuilder sb = new StringBuilder (); + sb.Append ("CONSTRAINT "); + sb.Append (constraint.Name); + sb.Append (' '); + + switch (constraint.ConstraintType) { + case ConstraintType.PrimaryKey: + //PrimaryKeyConstraintSchema pk = constraint as PrimaryKeyConstraintSchema; + sb.Append ("PRIMARY KEY"); //TODO: auto inc + sort + break; + case ConstraintType.Unique: + //UniqueConstraintSchema u = constraint as UniqueConstraintSchema; + sb.Append ("UNIQUE"); + break; + case ConstraintType.Check: + CheckConstraintSchema chk = constraint as CheckConstraintSchema; + sb.Append ("CHECK ("); + sb.Append (chk.Source); + sb.Append (")"); + break; + default: + throw new NotImplementedException (); + } + + return sb.ToString (); + } + + //http://www.sqlite.org/lang_createview.html + public override void CreateView (ViewSchema view) + { + IPooledDbConnection conn = connectionPool.Request (); + IDbCommand command = conn.CreateCommand (view.Definition); + using (command) + conn.ExecuteNonQuery (command); + conn.Release (); + } + + //http://www.sqlite.org/lang_createindex.html + public override void CreateIndex (IndexSchema index) + { + throw new NotImplementedException (); + } + + //http://www.sqlite.org/lang_createtrigger.html + public override void CreateTrigger (TriggerSchema trigger) + { + string sql = GetTriggerCreateStatement (trigger); + ExecuteNonQuery (sql); + } + + protected virtual string GetTriggerCreateStatement (TriggerSchema trigger) + { + StringBuilder sb = new StringBuilder (); + + sb.Append ("CREATE TRIGGER "); + sb.Append (trigger.Name); + + switch (trigger.TriggerType) { + case TriggerType.Before: + sb.Append (" BEFORE"); + break; + case TriggerType.After: + sb.Append (" AFTER"); + break; + default: + throw new NotImplementedException (); + } + + switch (trigger.TriggerEvent) { + case TriggerEvent.Insert: + sb.Append (" INSERT "); + break; + case TriggerEvent.Update: + sb.Append (" UPDATE "); + break; + case TriggerEvent.Delete: + sb.Append (" DELETE "); + break; + default: + throw new NotImplementedException (); + } + + sb.Append ("ON "); + sb.Append (trigger.TableName); + sb.Append (' '); + sb.Append (Environment.NewLine); + + switch (trigger.TriggerFireType) { + case TriggerFireType.ForEachRow: + case TriggerFireType.ForEachStatement: + sb.Append (" FOR EACH ROW "); + break; + default: + throw new NotImplementedException (); + } + + sb.Append (Environment.NewLine); + sb.Append ("BEGIN "); + sb.Append (Environment.NewLine); + sb.Append (trigger.Source); + sb.Append (' '); + sb.Append (Environment.NewLine); + sb.Append ("END;"); + + return sb.ToString (); + } + + //http://www.sqlite.org/lang_altertable.html + //http://www.sqlite.org/lang_vacuum.html + public override void AlterTable (TableSchema table) + { + throw new NotImplementedException (); + } + + public override void DropDatabase (DatabaseSchema db) + { + connectionPool.Close (); + System.IO.File.Delete (db.Name); + } + + //http://www.sqlite.org/lang_droptable.html + public override void DropTable (TableSchema table) + { + ExecuteNonQuery ("DROP TABLE IF EXISTS " + table.Name); + } + + //http://www.sqlite.org/lang_dropview.html + public override void DropView (ViewSchema view) + { + ExecuteNonQuery ("DROP VIEW IF EXISTS " + view.Name); + } + + //http://www.sqlite.org/lang_dropindex.html + public override void DropIndex (IndexSchema index) + { + ExecuteNonQuery ("DROP INDEX IF EXISTS " + index.Name); + } + + //http://www.sqlite.org/lang_droptrigger.html + public override void DropTrigger (TriggerSchema trigger) + { + ExecuteNonQuery ("DROP TRIGGER IF EXISTS " + trigger.Name); + } + + //http://www.sqlite.org/lang_altertable.html + public override void RenameTable (TableSchema table, string name) + { + ExecuteNonQuery ("ALTER TABLE " + table.Name + " RENAME TO " + name); + + table.Name = name; + } + + public override string GetViewAlterStatement (ViewSchema view) + { + return String.Concat ("DROP VIEW IF EXISTS ", view.Name, "; ", Environment.NewLine, view.Definition); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/AssemblyInfo.cs.in b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/AssemblyInfo.cs.in new file mode 100644 index 0000000000..7c18acace4 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/AssemblyInfo.cs.in @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("Mono.Data.Sql.Odbc")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("http://www.monodevelop.com")] +[assembly: AssemblyCopyright("MIT X11 - Christian Hergert, Daniel Morgan, Ben Motmans")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: AssemblyVersion("@ASSEMBLY_VERSION@")] + +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")]
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/ChangeLog b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/ChangeLog new file mode 100644 index 0000000000..1e623a00bc --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/ChangeLog @@ -0,0 +1,38 @@ +2007-10-29 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Sybase.addin.xml: Bump MD version. + +2007-10-23 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Sybase.mdp: Project file names updated by change + in MD path functions. + +2007-09-26 Michael Hutchinson <mhutchinson@novell.com> + + * MonoDevelop.Database.Sql.Sybase.mdp: Don't unnecessarily local-copy + project references. + +2007-09-21 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.Sybase.addin.xml: Bump MD version. + +2007-07-10 Ben Motmans <ben.motmans@gmail.com> + + * SybaseConnectionProvider.cs: set IsConnectionError property + +2007-07-05 Ben Motmans <ben.motmans@gmail.com> + + * SybaseConnectionProvider.cs: ExecuteQueryAsDataSet and ExecuteQueryAsDataTable implementation + * SybaseDbFactory.cs: specified the ISqlDialect and added default connection settings + +2007-07-02 Ben Motmans <ben.motmans@gmail.com> + + * SybaseSchemaProvider.cs: + Imported the old DbProvider and updated all to code to use the new API + +2007-07-01 Ben Motmans <ben.motmans@gmail.com> + + * SybaseSchemaProvider.cs: + * SybaseDbFactory.cs: + * SybaseConnectionProvider.cs: + Imported original code and splitted in 3 classes diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/MonoDevelop.Database.Sql.Sybase.addin.xml b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/MonoDevelop.Database.Sql.Sybase.addin.xml new file mode 100644 index 0000000000..ffe1d74cf5 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/MonoDevelop.Database.Sql.Sybase.addin.xml @@ -0,0 +1,21 @@ +<Addin id = "MonoDevelop.Database.Sql.Sybase" + namespace = "MonoDevelop" + name = "Sybase provider for Mono Data Sql" + author = "Christian Hergert, Daniel Morgan, Ben Motmans" + copyright = "MIT X11" + url = "http://www.monodevelop.com" + description = "Database Module" + version = "0.17.0"> + + <Runtime> + <Import assembly="MonoDevelop.Database.Sql.Sybase.dll"/> + </Runtime> + + <Dependencies> + <Addin id="MonoDevelop.Database.Sql" version="0.17.0"/> + </Dependencies> + + <Extension path = "/Mono/Data/Sql"> + <Class id = "Sybase" class = "MonoDevelop.Database.Sql.SybaseDbFactory"/> + </Extension> +</Addin>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/MonoDevelop.Database.Sql.Sybase.mdp b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/MonoDevelop.Database.Sql.Sybase.mdp new file mode 100644 index 0000000000..ecba6e5b9f --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/MonoDevelop.Database.Sql.Sybase.mdp @@ -0,0 +1,30 @@ +<Project name="MonoDevelop.Database.Sql.Sybase" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql.Sybase" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql.Sybase" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="False" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="SybaseSchemaProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="SybaseConnectionProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="MonoDevelop.Database.Sql.Sybase.addin.xml" subtype="Code" buildaction="FileCopy" /> + <File name="SybaseDbFactory.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema" subtype="Directory" buildaction="Compile" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="Mono.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" /> + <ProjectReference type="Gac" localcopy="True" refto="Mono.Data.SybaseClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" /> + <ProjectReference type="Gac" localcopy="True" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Database.Sql" /> + </References> +</Project>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/SybaseConnectionProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/SybaseConnectionProvider.cs new file mode 100644 index 0000000000..80e91afdb4 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/SybaseConnectionProvider.cs @@ -0,0 +1,114 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net> +// Daniel Morgan <danielmorgan@verizon.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc. +// Copyright (C) 2005 Daniel Morgan
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic; +using Mono.Data.SybaseClient;
+
namespace MonoDevelop.Database.Sql
+{
+ public class SybaseConnectionProvider : AbstractConnectionProvider
+ {
+ public SybaseConnectionProvider (IDbFactory factory, ConnectionSettings settings)
+ : base (factory, settings)
+ {
+ } +
+ public override bool SupportsPooling {
+ get { return false; }
+ } + + public override DataSet ExecuteQueryAsDataSet (string sql) + { + if (String.IsNullOrEmpty ("sql")) + throw new ArgumentException ("sql"); + + DataSet set = new DataSet (); + using (IDbCommand command = CreateCommand (sql)) { + using (SybaseDataAdapter adapter = new SybaseDataAdapter (command as SybaseCommand)) { + try { + adapter.Fill (set); + } catch { + } finally { + command.Connection.Close (); + } + } + } + return set; + } + + public override DataTable ExecuteQueryAsDataTable (string sql) + { + if (String.IsNullOrEmpty ("sql")) + throw new ArgumentException ("sql"); + + DataTable table = new DataTable (); + using (IDbCommand command = CreateCommand (sql)) { + using (SybaseDataAdapter adapter = new SybaseDataAdapter (command as SybaseCommand)) { + try { + adapter.Fill (table); + } catch { + } finally { + command.Connection.Close (); + } + } + } + return table; + }
+
+ public override IDbConnection Open (out string errorMessage)
+ { + string connStr = null;
+ try {
+ if (settings.UseConnectionString) { + connStr = settings.ConnectionString;
+ } else { + //Data Source='myASEserver';Port=5000;Database=myDataBase;Uid=myUsername;Pwd=myPassword; + connStr = String.Format ("Data Source='{0}';Port={1};Database={2};Uid={3};Pwd={4};", + settings.Server, settings.Port, settings.Database, settings.Username, settings.Password);
+ } + SetConnectionStringParameter (connStr, String.Empty, "pooling", settings.EnablePooling.ToString ()); + if (settings.EnablePooling) { + SetConnectionStringParameter (connStr, String.Empty, "MinPoolSize", settings.MinPoolSize.ToString ()); + SetConnectionStringParameter (connStr, String.Empty, "MaxPoolSize", settings.MaxPoolSize.ToString ()); + }
+ connection = new SybaseConnection (connStr);
+ connection.Open ();
+
+ errorMessage = String.Empty;
+ isConnectionError = false;
+ return connection;
+ } catch { + isConnectionError = true;
+ errorMessage = String.Format ("Unable to connect. (CS={0})", connStr == null ? "NULL" : connStr);
+ return null;
+ }
+ }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/SybaseDbFactory.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/SybaseDbFactory.cs new file mode 100644 index 0000000000..8ec4c7904b --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/SybaseDbFactory.cs @@ -0,0 +1,73 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic;
+
namespace MonoDevelop.Database.Sql
+{
+ public class SybaseDbFactory : IDbFactory
+ { + private ISqlDialect dialect; + + public string Identifier { + get { return "Mono.Data.SybaseClient"; } + } +
+ public string Name { + get { return "Sybase database (Incomplete)"; } + } + + public ISqlDialect Dialect { + get { + if (dialect == null) + dialect = new Sql99Dialect ("\"", "@"); + return dialect; + } + } + + public IConnectionProvider CreateConnectionProvider (ConnectionSettings settings) + { + return new SybaseConnectionProvider (this, settings); + } + + public ISchemaProvider CreateSchemaProvider (IConnectionProvider connectionProvider) + { + return new SybaseSchemaProvider (connectionProvider); + } + + public ConnectionSettings GetDefaultConnectionSettings () + { + ConnectionSettings settings = new ConnectionSettings (); + settings.ProviderIdentifier = Identifier; + settings.Server = "localhost"; + settings.Port = 4100; + settings.Username = "sa"; + settings.Password = String.Empty; + settings.Database = String.Empty; + return settings; + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/SybaseSchemaProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/SybaseSchemaProvider.cs new file mode 100644 index 0000000000..cdbaf155da --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Sybase/SybaseSchemaProvider.cs @@ -0,0 +1,358 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net> +// Daniel Morgan <danielmorgan@verizon.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Mosaix Communications, Inc. +// Copyright (C) 2005 Daniel Morgan
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Text; +using System.Data;
+using System.Collections.Generic; +using Mono.Data.SybaseClient;
+
namespace MonoDevelop.Database.Sql
+{
+ public class SybaseSchemaProvider : AbstractSchemaProvider
+ {
+ public SybaseSchemaProvider (IConnectionProvider connectionProvider)
+ : base (connectionProvider)
+ {
+ } + + public override bool SupportsSchemaType (Type type)
+ {
+ if (type == typeof(TableSchema)) + return true; + else if (type == typeof(ColumnSchema)) + return true; + else if (type == typeof(ViewSchema)) + return true; + else if (type == typeof(ProcedureSchema)) + return true; + else if (type == typeof(UserSchema)) + return true; + else if (type == typeof(SequenceSchema)) + return true; + else if (type == typeof(TriggerSchema)) + return true; + else + return false;
+ }
+
+ public override ICollection<TableSchema> GetTables ()
+ {
+ CheckConnectionState ();
+ List<TableSchema> tables = new List<TableSchema> ();
+
+ IDbCommand command = connectionProvider.CreateCommand ( + "SELECT su.name AS owner, so.name as table_name, so.id as table_id, " + + " so.crdate as created_date, so.type as table_type " + + "FROM dbo.sysobjects so, dbo.sysusers su " + + "WHERE type IN ('S','U') " + + "AND su.uid = so.uid " + + "ORDER BY 1, 2" + );
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ TableSchema table = new TableSchema (this);
+
+ table.Name = r.GetString(1); + table.IsSystemTable = r.GetString (4) == "S" ? true : false; + + table.SchemaName = r.GetString (0); + table.OwnerName = r.GetString (0); + table.Comment = ""; + + StringBuilder sb = new StringBuilder(); + sb.AppendFormat ("-- Table: {0}\n", table.Name); + sb.AppendFormat ("-- DROP TABLE {0};\n\n", table.Name); + sb.AppendFormat ("CREATE TABLE {0} (\n", table.Name); + + ICollection<ColumnSchema> columns = table.Columns; + string[] parts = new string[columns.Count]; + int i = 0;
+ foreach (ColumnSchema col in columns)
+ parts[i++] = col.Definition; + sb.Append (String.Join (",\n", parts)); + + ICollection<ConstraintSchema> constraints = table.Constraints; + parts = new string[constraints.Count]; + if (constraints.Count > 0) + sb.Append (",\n"); + i = 0;
+ foreach (ConstraintSchema constr in constraints)
+ parts[i++] = "\t" + constr.Definition; + sb.Append (String.Join (",\n", parts)); + + sb.Append ("\n);\n"); + //sb.AppendFormat ("COMMENT ON TABLE {0} IS '{1}';", table.Name, table.Comment); + table.Definition = sb.ToString();
+
+ tables.Add (table);
+ } + r.Close ();
+ } + connectionProvider.Close (command.Connection);
+ }
+
+ return tables;
+ }
+
+ public override ICollection<ColumnSchema> GetTableColumns (TableSchema table)
+ {
+ CheckConnectionState ();
+ List<ColumnSchema> columns = new List<ColumnSchema> ();
+
+ IDbCommand command = connectionProvider.CreateCommand ( + "select su.name as owner, so.name as table_name, sc.name as column_name, " + + " st.name as date_type, sc.length as column_length, " + + " sc.prec as data_preceision, sc.scale as data_scale, " + + " 0 as isnullable, sc.colid as column_id " + + "from dbo.syscolumns sc, dbo.sysobjects so, " + + " dbo.systypes st, dbo.sysusers su " + + "where sc.id = so.id " + + "and so.type in ('U','S') " + + "and so.name = '" + table.Name + "' " + + "and su.name = '" + table.OwnerName + "' " + + "and su.uid = so.uid " + + "and sc.usertype = st.usertype " + + "order by sc.colid" + );
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ColumnSchema column = new ColumnSchema (this); + + column.Name = r.GetString (2);
+ column.DataTypeName = r.GetString (3);
+ column.OwnerName = table.OwnerName;
+ column.NotNull = r.GetInt32 (7) == 8 ? true : false;
+ column.Length = GetCheckedInt32 (r, 4);
+ column.Precision = GetCheckedInt32 (r, 5);
+ column.Scale = GetCheckedInt32 (r, 6);
+
+ StringBuilder sb = new StringBuilder ();
+ sb.AppendFormat ("{0} {1}{2}",
+ column.Name,
+ column.DataTypeName,
+ (column.Length > 0) ? ("(" + column.Length + ")") : "");
+ sb.AppendFormat (" {0}", column.NotNull ? "NOT NULL" : "NULL");
+ if (column.Default.ToString ().Length > 0)
+ sb.AppendFormat (" DEFAULT {0}", column.Default.ToString ());
+ column.Definition = sb.ToString ();
+
+ columns.Add (column);
+ } + r.Close ();
+ } + connectionProvider.Close (command.Connection);
+ }
+
+ return columns;
+ }
+
+ public override ICollection<ViewSchema> GetViews ()
+ {
+ CheckConnectionState ();
+ List<ViewSchema> views = new List<ViewSchema> ();
+
+ IDbCommand command = connectionProvider.CreateCommand (
+ "SELECT su.name AS owner, so.name as table_name, so.id as table_id, " + + " so.crdate as created_date, so.type as table_type " + + "FROM dbo.sysobjects so, dbo.sysusers su " + + "WHERE type = 'V' " + + "AND su.uid = so.uid " + + "ORDER BY 1, 2"
+ );
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ViewSchema view = new ViewSchema (this);
+
+ view.Name = r.GetString (1); + view.SchemaName = r.GetString (0); + view.OwnerName = r.GetString (0); + view.IsSystemView = r.GetString (4).Trim ().Equals ("S"); + + StringBuilder sb = new StringBuilder (); + sb.AppendFormat ("-- View: {0}\n", view.Name); + sb.AppendFormat ("-- DROP VIEW {0};\n\n", view.Name); + string source = GetSource (view.Owner + "." + view.Name); + sb.AppendFormat (" {0}\n);", source); + view.Definition = sb.ToString (); + //view.Comment = r.GetString(5); +
+ views.Add (view);
+ } + r.Close ();
+ } + connectionProvider.Close (command.Connection);
+ }
+ return views;
+ }
+
+ public override ICollection<ColumnSchema> GetViewColumns (ViewSchema view)
+ {
+ CheckConnectionState ();
+ List<ColumnSchema> columns = new List<ColumnSchema> ();
+
+ IDbCommand command = connectionProvider.CreateCommand ( + "SELECT * " + + " FROM " + view.Name + + " WHERE 1 = 0" + );
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) { + for (int i = 0; i < r.FieldCount; i++) { + ColumnSchema column = new ColumnSchema (this);
+ + column.Name = r.GetName (i); + column.DataTypeName = r.GetDataTypeName (i); + column.OwnerName = view.OwnerName; + column.SchemaName = view.OwnerName;
+
+ columns.Add (column); + }
+ } + r.Close ();
+ } + connectionProvider.Close (command.Connection);
+ }
+
+ return columns;
+ }
+
+ public override ICollection<ProcedureSchema> GetProcedures ()
+ {
+ CheckConnectionState ();
+ List<ProcedureSchema> procedures = new List<ProcedureSchema> ();
+
+ IDbCommand command = connectionProvider.CreateCommand (
+ "SELECT su.name AS owner, so.name as proc_name, so.id as proc_id, "
+ + "so.crdate as created_date, so.type as proc_type "
+ + "FROM dbo.sysobjects so, dbo.sysusers su "
+ + "WHERE type = 'P' AND su.uid = so.uid "
+ + "ORDER BY 1, 2"
+ );
+
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) {
+ ProcedureSchema procedure = new ProcedureSchema (this); + + procedure.Name = r.GetString (1); + procedure.OwnerName = r.GetString (0); + procedure.IsSystemProcedure = r.GetString (4).Trim ().Equals ("S"); + + StringBuilder sb = new StringBuilder (); + sb.AppendFormat ("-- Procedure: {0}\n", procedure.Name); + sb.AppendFormat ("-- DROP PROCEDURE {0};\n\n", procedure.Name); + string source = GetSource (procedure.Owner + "." + procedure.Name); + sb.AppendFormat (" {0}\n);", source); + procedure.Definition = sb.ToString ();
+
+ procedures.Add (procedure);
+ } + r.Close ();
+ } + connectionProvider.Close (command.Connection);
+ }
+
+ return procedures;
+ }
+
+ public override ICollection<ColumnSchema> GetProcedureColumns (ProcedureSchema procedure)
+ {
+ CheckConnectionState ();
+ List<ColumnSchema> columns = new List<ColumnSchema> (); + +
+ IDbCommand command = connectionProvider.CreateCommand ( + "sp_sproc_columns"
+ ); + SybaseParameter owner = new SybaseParameter ("@procedure_owner", procedure.OwnerName);
+ SybaseParameter name = new SybaseParameter ("@procedure_name", procedure.Name);
+ command.Parameters.Add (owner); + command.Parameters.Add (name);
+
+ using (command) {
+ using (IDataReader r = command.ExecuteReader()) {
+ while (r.Read ()) { + ColumnSchema column = new ColumnSchema (this); + column.Name = (string)r["COLUMN_NAME"];
+ column.DataTypeName = (string)r["TYPE_NAME"]; + columns.Add (column);
+ } + r.Close ();
+ } + connectionProvider.Close (command.Connection);
+ }
+
+ return columns;
+ }
+
+ public override DataTypeSchema GetDataType (string name)
+ {
+ if (name == null)
+ throw new ArgumentNullException ("name");
+ name = name.ToUpper ();
+
+ DataTypeSchema dts = new DataTypeSchema (this);
+ dts.Name = name;
+ switch (name) {
+ //TODO: IMPLEMENT
+ case "":
+ break;
+ default:
+ dts = null; + break;
+ }
+
+ return dts;
+ } + + protected string GetSource (string objectName) + { + CheckConnectionState ();
+
+ IDbCommand command = connectionProvider.CreateCommand ( + String.Format ("EXEC [master].[dbo].[sp_helptext] '{0}', null", objectName) + ); + StringBuilder sb = new StringBuilder ();
+ using (command) {
+ using (IDataReader r = command.ExecuteReader ()) { + while (r.Read ()) + sb.Append (r.GetString (0)); + r.Close (); + } + connectionProvider.Close (command.Connection); + } + + return sb.ToString (); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Tests/MonoDevelop.Database.Sql.Tests.mdp b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Tests/MonoDevelop.Database.Sql.Tests.mdp new file mode 100644 index 0000000000..0db906d09c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql.Tests/MonoDevelop.Database.Sql.Tests.mdp @@ -0,0 +1,20 @@ +<Project name="MonoDevelop.Database.Sql.Tests" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="bin/Debug" assembly="MonoDevelop.Database.Sql.Tests" /> + <Build debugmode="True" target="Exe" /> + <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="bin/Release" assembly="MonoDevelop.Database.Sql.Tests" /> + <Build debugmode="False" target="Exe" /> + <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + </References> +</Project>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/AbstractDbFactory.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/AbstractDbFactory.cs new file mode 100644 index 0000000000..22a4c683b3 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/AbstractDbFactory.cs @@ -0,0 +1,142 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public abstract class AbstractDbFactory : IDbFactory + { + protected Dictionary<string, SchemaActions> supportedActions; + protected Dictionary<string, Dictionary<SchemaActions, int>> capabilities; + + protected AbstractDbFactory () + { + supportedActions = new Dictionary<string,SchemaActions> (); + capabilities = new Dictionary<string,Dictionary<SchemaActions,int>> (); + } + + public abstract string Identifier { get; } + + public abstract string Name { get; } + + public abstract ISqlDialect Dialect { get; } + + public abstract IConnectionProvider ConnectionProvider { get; } + + public abstract IGuiProvider GuiProvider { get; } + + public abstract DatabaseConnectionSettings GetDefaultConnectionSettings (); + + public abstract IConnectionPool CreateConnectionPool (MonoDevelop.Database.Sql.DatabaseConnectionContext context); + + public abstract ISchemaProvider CreateSchemaProvider (MonoDevelop.Database.Sql.IConnectionPool connectionPool); + + public SchemaActions GetSupportedActions (string category) + { + if (category == null) + throw new ArgumentNullException ("category"); + + SchemaActions actions; + if (supportedActions.TryGetValue (category, out actions)) + return actions; + return SchemaActions.None; + } + + public void SetSupportedActions (string category, SchemaActions actions) + { + if (category == null) + throw new ArgumentNullException ("category"); + + if (supportedActions.ContainsKey (category)) { + SchemaActions tmp = supportedActions[category]; + tmp |= actions; + supportedActions[category] = tmp; + } else { + supportedActions.Add (category, actions); + } + } + + public bool IsActionSupported (string category, SchemaActions action) + { + SchemaActions actions = GetSupportedActions (category); + return (actions & action) == action; + } + + public int GetCapabilities (string category, SchemaActions action) + { + if (category == null) + throw new ArgumentNullException ("category"); + + Dictionary<SchemaActions, int> dict = null; + if (capabilities.TryGetValue (category, out dict)) { + int val; + if (dict.TryGetValue (action, out val)) + return val; + } + return 0; + } + + public void SetCapabilities (string category, SchemaActions action, int flags) + { + if (category == null) + throw new ArgumentNullException ("category"); + if (flags < 0) + throw new ArgumentException ("flags must be >= 0"); + + foreach (int val in Enum.GetValues (typeof (SchemaActions))) { + if (val == 0) //skip SchemaActions.None + continue; + + if ((val & (int)action) == val) { + if (!capabilities.ContainsKey (category)) + capabilities.Add (category, new Dictionary<SchemaActions, int> ()); + + Dictionary<SchemaActions, int> dict = capabilities[category]; + if (dict.ContainsKey ((SchemaActions)val)) { + int tmp = dict[(SchemaActions)val]; + tmp |= flags; + dict[(SchemaActions)val] = tmp; + } else { + dict.Add ((SchemaActions)val, flags); + } + } + } + } + + public bool IsCapabilitySupported (string category, SchemaActions action, Enum capability) + { + if (category == null) + throw new ArgumentNullException ("category"); + + int lookup = GetCapabilities (category, action); + int value = (int)capability; + + return (lookup & value) == value; + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/AssemblyInfo.cs.in b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/AssemblyInfo.cs.in new file mode 100644 index 0000000000..04d4e0a202 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/AssemblyInfo.cs.in @@ -0,0 +1,16 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("MonoDevelop.Database.Sql")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("http://www.monodevelop.com")] +[assembly: AssemblyCopyright("MIT X11 - Christian Hergert, Ben Motmans")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: AssemblyVersion("@ASSEMBLY_VERSION@")] + +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/CapabilitiesUtility.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/CapabilitiesUtility.cs new file mode 100644 index 0000000000..f86a4b4fdf --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/CapabilitiesUtility.cs @@ -0,0 +1,85 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Sql +{ + public static class CapabilitiesUtility + { + private static Dictionary<string, Type> types; + + static CapabilitiesUtility () + { + types = new Dictionary<string, Type> (); + + foreach (CapabilityFlagsCodon codon in AddinManager.GetExtensionNodes ("/MonoDevelop/Database/Capabilities")) + Register (codon.Category, codon.Type); + } + + public static void Register (string category, Type type) + { + if (category == null) + throw new ArgumentNullException ("category"); + if (type == null) + throw new ArgumentNullException ("type"); + + if (types.ContainsKey (category)) { + types[category] = type; + LoggingService.LogWarning ("Duplicate CapabilityFlags for category {0}.", category); + } else { + types.Add (category, type); + } + } + + public static int Parse (string category, string flags) + { + if (category == null) + throw new ArgumentNullException ("category"); + + Type type = null; + if (!string.IsNullOrEmpty (flags) && types.TryGetValue (category, out type)) { + object obj = Enum.Parse (type, flags, true); + return (int)obj; + } + return 0; + } + + public static Type GetType (string category) + { + if (category == null) + throw new ArgumentNullException ("category"); + + Type type = null; + if (types.TryGetValue (category, out type)) + return type; + return null; + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/CheckConstraint.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/CheckConstraint.cs new file mode 100644 index 0000000000..d3886071ed --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/CheckConstraint.cs @@ -0,0 +1,43 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{ + [Flags]
+ public enum CheckConstraintCapabilities
+ { + None = 0x00, + + Name = 0x01, + Owner = 0x02, + Definition = 0x04, + Schema = 0x08, + IsColumnConstraint = 0x10, + Columns = 0x20, + Source = 0x40
+ }
+} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Column.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Column.cs new file mode 100644 index 0000000000..f4de84b9cb --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Column.cs @@ -0,0 +1,59 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{ + [Flags]
+ public enum ColumnCapabilities
+ { + None = 0x00000, + + Name = 0x00001, + Owner = 0x00002, + Comment = 0x00004, + Definition = 0x00008, + Schema = 0x00010, + DataType = 0x00020, + DefaultValue = 0x00040, + Nullable = 0x00080, + Length = 0x00100, + Precision = 0x00200, + Scale = 0x00400, + Position = 0x00800, + + PrimaryKeyConstraint = 0x01000, + ForeignKeyConstraint = 0x02000, + CheckConstraint = 0x04000, + UniqueConstraint = 0x08000, + + Constraints = PrimaryKeyConstraint | ForeignKeyConstraint | CheckConstraint | UniqueConstraint, + + AppendConstraint = 0x10000, + InsertConstraint = 0x20000, + RemoveConstraint = 0x40000
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/ConnectionSettings.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/ConnectionSettings.cs new file mode 100644 index 0000000000..b3008441c0 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/ConnectionSettings.cs @@ -0,0 +1,42 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{ + [Flags]
+ public enum ConnectionSettingsCapabilities
+ { + None = 0x00, + + Username = 0x01, + Password = 0x02, + Server = 0x04, + Port = 0x08, + ListDatabases = 0x10, + SelectDatabase = 0x20
+ }
+} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/ForeignKeyConstraint.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/ForeignKeyConstraint.cs new file mode 100644 index 0000000000..3e2e459097 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/ForeignKeyConstraint.cs @@ -0,0 +1,49 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{ + [Flags]
+ public enum ForeignKeyConstraintCapabilities
+ { + None = 0x0000, + + Name = 0x0001, + Owner = 0x0002, + Definition = 0x0004, + Schema = 0x0008, + IsColumnConstraint = 0x0010, + Columns = 0x0020, + ReferenceTable = 0x0040, + ReferenceColumns = 0x0080, + Cascade = 0x0100, + Restrict = 0x0200, + NoAction = 0x0400, + SetDefault = 0x0800, + SetNull = 0x1000
+ }
+} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Index.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Index.cs new file mode 100644 index 0000000000..fa5fe467c6 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Index.cs @@ -0,0 +1,46 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{ + [Flags]
+ public enum IndexCapabilities
+ { + None = 0x000, + + Name = 0x001, + Owner = 0x002, + Comment = 0x004, + Definition = 0x008, + Schema = 0x010, + TableName = 0x020, + IndexType = 0x040, + Columns = 0x080, + ColumnLength = 0x100, + ColumnSort = 0x200
+ }
+} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Parameter.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Parameter.cs new file mode 100644 index 0000000000..adcdcbf680 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Parameter.cs @@ -0,0 +1,44 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{ + [Flags]
+ public enum ParameterCapabilities
+ { + None = 0x00, + + Name = 0x01, + Owner = 0x02, + Comment = 0x04, + Definition = 0x08, + Schema = 0x10, + DataType = 0x20, + Position = 0x40, + Direction = 0x80
+ }
+} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/PrimaryKeyConstraint.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/PrimaryKeyConstraint.cs new file mode 100644 index 0000000000..4579d8b732 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/PrimaryKeyConstraint.cs @@ -0,0 +1,42 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{ + [Flags]
+ public enum PrimaryKeyConstraintCapabilities
+ { + None = 0x00, + + Name = 0x01, + Owner = 0x02, + Definition = 0x04, + Schema = 0x08, + IsColumnConstraint = 0x10, + Columns = 0x20
+ }
+} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Procedure.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Procedure.cs new file mode 100644 index 0000000000..353ec2a731 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Procedure.cs @@ -0,0 +1,48 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{ + [Flags]
+ public enum ProcedureCapabilities
+ { + None = 0x000, + + Name = 0x001, + Owner = 0x002, + Comment = 0x004, + Definition = 0x008, + Schema = 0x010, + IsSystem = 0x020, + Language = 0x040, + Parameters = 0x080, + + InsertParameter = 0x100, + AppendParameter = 0x200, + RemoveParameter = 0x400
+ }
+} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/SchemaActions.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/SchemaActions.cs new file mode 100644 index 0000000000..296df38d17 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/SchemaActions.cs @@ -0,0 +1,44 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{ + [Flags]
+ public enum SchemaActions
+ { + None = 0x00, + + Schema = 0x01, + + Create = 0x02, + Alter = 0x04, + Drop = 0x08, + Rename = 0x10, + + All = Schema | Create | Alter | Drop | Rename
+ }
+} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Table.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Table.cs new file mode 100644 index 0000000000..d5fadbdffc --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Table.cs @@ -0,0 +1,65 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{ + [Flags]
+ public enum TableCapabilities
+ { + None = 0x000000, + + Name = 0x000001, + TableSpaceName = 0x000002, + Owner = 0x000004, + Comment = 0x000008, + Definition = 0x000010, + Schema = 0x000020, + IsSystem = 0x000040, + Columns = 0x000080, + + PrimaryKeyConstraint = 0x000100, + ForeignKeyConstraint = 0x000200, + CheckConstraint = 0x000400, + UniqueConstraint = 0x000800, + + Constraints = PrimaryKeyConstraint | ForeignKeyConstraint | CheckConstraint | UniqueConstraint, + + AppendConstraint = 0x001000, + InsertConstraint = 0x002000, + RemoveConstraint = 0x004000, + + Trigger = 0x008000, + + AppendTrigger = 0x010000, + InsertTrigger = 0x020000, + RemoveTrigger = 0x040000, + + AppendColumn = 0x080000, + InsertColumn = 0x100000, + RemoveColumn = 0x200000
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Trigger.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Trigger.cs new file mode 100644 index 0000000000..e95530489a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/Trigger.cs @@ -0,0 +1,48 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{ + [Flags]
+ public enum TriggerCapabilities
+ { + None = 0x000, + + Name = 0x001, + Owner = 0x002, + Comment = 0x004, + Definition = 0x008, + Schema = 0x010, + TableName = 0x020, + TriggerType = 0x040, + TriggerEvent = 0x080, + TriggerFireType = 0x100, + Position = 0x200, + IsActive = 0x400, + Source = 0x800
+ }
+} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/UniqueConstraint.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/UniqueConstraint.cs new file mode 100644 index 0000000000..d71df42fd0 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/UniqueConstraint.cs @@ -0,0 +1,42 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{ + [Flags]
+ public enum UniqueConstraintCapabilities
+ { + None = 0x00, + + Name = 0x01, + Owner = 0x02, + Definition = 0x04, + Schema = 0x08, + IsColumnConstraint = 0x10, + Columns = 0x20
+ }
+} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/User.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/User.cs new file mode 100644 index 0000000000..5622053c1d --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/User.cs @@ -0,0 +1,44 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{ + [Flags]
+ public enum UserCapabilities
+ { + None = 0x000, + + Name = 0x001, + Owner = 0x002, + Comment = 0x004, + Definition = 0x008, + Schema = 0x010, + Username = 0x020, + Password = 0x040, + PasswordExpiration = 0x080
+ }
+} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/View.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/View.cs new file mode 100644 index 0000000000..f88062cbb7 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Capabilities/View.cs @@ -0,0 +1,48 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{ + [Flags]
+ public enum ViewCapabilities
+ { + None = 0x00, + + Name = 0x001, + Owner = 0x002, + Comment = 0x004, + Definition = 0x008, + Schema = 0x010, + IsSystem = 0x020, + Statement = 0x040, + Columns = 0x080, + + AppendColumn = 0x100, + InsertColumn = 0x200, + RemoveColumn = 0x400
+ }
+} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ChangeLog b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ChangeLog new file mode 100644 index 0000000000..8e098358f5 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ChangeLog @@ -0,0 +1,764 @@ +2007-11-09 Michael Hutchinson <mhutchinson@novell.com> + + * Codons/DbFactoryCodon.cs, ConnectionContextService.cs, + Capabilities/CapabilitiesUtility.cs, + ConnectionPool/AbstractPooledDbConnection.cs, QueryService.cs, + DbFactoryService.cs: Track LoggingService API. Replace some "LogError" + calls with "LogDebug" calls. + +2007-10-29 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.addin.xml: Bump MD version. + +2007-10-23 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.mdp: Project file names updated by change in MD + path functions. + +2007-10-02 Ben Motmans <ben.motmans@gmail.com> + + * QueryService.cs: Allow empty passwords + +2007-09-26 Michael Hutchinson <mhutchinson@novell.com> + + * MonoDevelop.Database.Sql.mdp: Don't unnecessarily local-copy project + references. Don't sync EXTRA_DIST with deploy files. Add Makefile.am to + file list. + * Makefile.am: Don't deploy .addin.xml file. + +2007-09-21 Lluis Sanchez Gual <lluis@novell.com> + + * MonoDevelop.Database.Sql.addin.xml: Bump MD version. + +2007-09-19 Ben Motmans <ben.motmans@gmail.com> + + * ConnectionPool/DefaultConnectionPool.cs: improved detection of connection + errors + * QueryService.cs: removed the obsolete attempt parameter + +2007-09-19 Ben Motmans <ben.motmans@gmail.com> + + * Capabilities/UniqueConstraint.cs, Capabilities/User.cs, + Capabilities/Parameter.cs, Capabilities/ConnectionSettings.cs, + Capabilities/SchemaActions.cs, Capabilities/CheckConstraint.cs, + Capabilities/Table.cs, Capabilities/Procedure.cs, + Capabilities/Column.cs, Capabilities/PrimaryKeyConstraint.cs, + Capabilities/Trigger.cs, Capabilities/ForeignKeyConstraint.cs, + Capabilities/Index.cs, Capabilities/View.cs: added values to the enum + +2007-09-17 Ben Motmans <ben.motmans@gmail.com> + + + +2007-09-16 Ben Motmans <ben.motmans@gmail.com> + + * Codons/DbFactoryCodon.cs: log errors + * Codons/CapabilityFlagsCodon.cs: Read overload is no longer needed, this is + done in the CapabilitiesUtility + * Capabilities/CapabilitiesUtility.cs: register capability flags on load and + correctly parse the flags + * AbstractDbFactory.cs: small bugfix in SetCapabilities method + * MonoDevelop.Database.Sql.addin.xml: small changes in the extension points + * Makefile.am: link to the correct Mono.Addins dll + +2007-09-07 Ben Motmans <ben.motmans@gmail.com> + + * MetaData, MetaData/ViewMetaData.cs, MetaData/DataTypeMetaData.cs, + MetaData/UniqueConstraintMetaData.cs, MetaData/UserMetaData.cs, + MetaData/ConnectionSettingsMetaData.cs, MetaData/ParameterMetaData.cs, + MetaData/CheckConstraintMetaData.cs, MetaData/TableMetaData.cs, + MetaData/ProcedureMetaData.cs, MetaData/ColumnMetaData.cs, + MetaData/MetaDataService.cs, MetaData/PrimaryKeyConstraintMetaData.cs, + MetaData/TriggerMetaData.cs, MetaData/DatabaseMetaData.cs, + MetaData/ForeignKeyConstraintMetaData.cs, MetaData/IndexMetaData.cs, + Codons/CapabilitiesCodon.cs, Codons/DbFactoryCodon.cs, + Codons/ActionCodon.cs, Codons/CapabilityFlagsCodon.cs, Capabilities, + Capabilities/UniqueConstraint.cs, Capabilities/CapabilitiesUtility.cs, + Capabilities/User.cs, Capabilities/Parameter.cs, + Capabilities/ConnectionSettings.cs, Capabilities/SchemaActions.cs, + Capabilities/CheckConstraint.cs, Capabilities/Table.cs, + Capabilities/Procedure.cs, Capabilities/Column.cs, + Capabilities/PrimaryKeyConstraint.cs, Capabilities/Trigger.cs, + Capabilities/ForeignKeyConstraint.cs, Capabilities/Index.cs, + Capabilities/View.cs, ConnectionContextService.cs, IDbFactory.cs, + QueryService.cs, AbstractDbFactory.cs, + MonoDevelop.Database.Sql.addin.xml, MonoDevelop.Database.Sql.mdp: + improved capabilities system + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * MonoDevelop.Database.Sql.mdp, Makefile.am: use project references instead + of assembly references + +2007-08-28 Ben Motmans <ben.motmans@gmail.com> + + * MetaData/MetaDataService.cs: support for IndexMetaDataAttribute + * MetaData/ForeignKeyConstraintMetaData.cs, + Schema/ForeignKeyConstraintSchema.cs: added reference columns property + to foreign keys + * MetaData/IndexMetaData.cs: Index metadata attribute + * Schema/ForeignKeyAction.cs: available foreign key actions + * Schema/IndexType.cs: available index types + * Schema/IndexSchema.cs: added IndexType property + * Makefile.am: updated makefile + +2007-08-03 Ben Motmans <ben.motmans@gmail.com> + + * ConnectionContextService.cs: initialize the correct configFile field + + * Providers/IConnectionProvider.cs, Providers/AbstractConnectionProvider.cs: + included an out parameter to pass connection errors + * ConnectionPool/IConnectionPool.cs, ConnectionPool/DefaultConnectionPool.cs, + ConnectionPool/FakeConnectionPool.cs: added support to store errors that occured + while creating new connections + +2007-08-02 Ben Motmans <ben.motmans@gmail.com> + + * MetaData/ConnectionSettingsMetaData.cs: fixed incorrect field initializer in ctor + + * Collections/ConstraintSchemaCollection.cs: added GetConstraints method to get all + constraints of a specified type + * Schema/TriggerSchema.cs, Schema/TriggerFireType.cs: added a property to distinguish + for each row and for each statement triggers + +2007-08-01 Ben Motmans <ben.motmans@gmail.com> + + * Providers/AbstractSchemaProvider.cs, Providers/ISchemaProvider.cs: IsValidName method + * Configuration/DatabaseConnectionContextCollection.cs: Contains method that can + look for a specific name + * Configuration/DatabaseConnectionContext.cs: Refresh event + + * Schema/ViewSchema.cs, Schema/TableSchema.cs: update column parent after clone + * Schema/ColumnSchema.cs, Schema/DataTypeSchema.cs: store length, scale and precision + information in the datatype and not in the column + * Providers/AbstractSchemaProvider.cs, Providers/ISchemaProvider.cs: added methods + to get the create or alter statements from some schema objects + * Dialect/AbstractSqlDialect.cs: fixed incorrectly generated sql statements + * ConnectionPool/IPooledDbConnection.cs, ConnectionPool/AbstractPooledDbConnection.cs: + Added helper methods to quickly execute sql statements + * ConnectionContextService.cs: automatically initialize + +2007-07-31 Ben Motmans <ben.motmans@gmail.com> + + * QueryService.cs: Added a global method to raise database exceptions + * Providers/IGuiProvider.cs, IDbFactory.cs: Moved all Gui operations + in a separate Gui provider + * Providers/ISchemaProvider.cs, Providers/AbstractSchemaProvider.cs: + Methods to create new schema objects + * MetaData/*.cs: Added more metadata flags + * Collections/*.cs: Added a copy constructor + * Schema/*.cs: Added a copy constructor and implemented IClonable + +2007-07-25 Ben Motmans <ben.motmans@gmail.com> + + * Schema/TableSchema.cs: added additional constructor that initializes all properties + * Schema/ParameterSchema.cs, Schema/ParameterType.cs: Added a property to + define the parameter direction (in, out, inout) + * Schema/IndexSortType.cs, Schema/IndexSchema.cs: Indices no longer subclass + constraints but are a type on its own + * Schema/DataTypeSchema.cs: added properties for the create format, auto inc, + isNullable and isFixedLength + * Schema/ConstraintType.cs: enum containing the different types of constraints + * Schema/ConstraintSchema.cs: property to distinguish the difference between + table and column constraints + * Providers/ISchemaProvider.cs, Providers/AbstractSchemaProvider.cs: Seperate + methods to get indices and constraints + * MetaData/*.cs: attributes and enumerations to store information about + database capabilities and features + * ConnectionPool/AbstractPooledDbConnection.cs, ConnectionPool/IPooledDbConnection.cs: + Expose the GetSchema method of the internal IDbConnection + * Configuration/DatabaseConnectionContext.cs: added support for temp contexts + to be used in the create database dialog + * Configuration/DatabaseConnectionSettings.cs: added a copy constructor + * Collections/ConstraintSchemaCollection.cs, Collections/DataTypeSchemaCollection.cs, + Collections/IndexSchemaCollection.cs: strong typed schema collections + * Collections/SortedCollectionItemEventArgs.cs: EventArgs to be used in + Add and Remove events + +2007-07-18 Ben Motmans <ben.motmans@gmail.com> + + * Providers/ISchemaProvider.cs, Providers/AbstractSchemaProvider.cs: Create, Alter, Drop + and Rename methods for schema objects + * Providers/SchemaOperation.cs, Schema/SqlSchemaType.cs, Dialect/Statements/SqlStatementType.cs: + Improved method to determine if a schema operation is supported, no longer requires type checking + * Schema/CheckConstraintSchema.cs: Source property + * Schema/IndexConstraintSchema.cs, Schema/IndexConstraintSortType.cs: TableName and SortType properties + * Schema/TriggerSchema.cs, Schema/TriggerEvent.cs, Schema/TriggerType.cs: Extended the + TriggerSchema object to include the event, type and position of the trigger + * Collections/SortedCollectionBase.cs: Generic collection implementation with support + for sorted ISchema objects and a binary searche based on the ISchema name + * Collections/*SchemaCollection.cs: strong typed schema collections + * QueryService.cs: no longer shows the edit dialog after a failed attempt + +2007-07-17 Ben Motmans <ben.motmans@gmail.com> + + * Makefile.am: initial makefile + * Configuration/*.cs: moved ConnectionSettings class and splitted into DatabaseConnectionSettings + and DatabaseConnectionContext + * QueryService.cs: service to easily ensure the connection state + * IDbFactory.cs: additional methods required for the connection settings dialog + * ConnectionPool/FakeConnectionPool.cs: fake connection pool for use with temporary connections + +2007-07-15 Ben Motmans <ben.motmans@gmail.com> + + * Dialect/ISqlDialect.cs, Dialect/AbstractSqlDialect.cs: replaced QuoteChar and ParameterChar + properties with methods to allow more complex behavior + * Dialect/Sql99Dialect.cs: removed, all providers should implement their own unique dialect + * Dialect/AbstractSqlDialect.cs: support FromSelectClause and FromTableClause in GetSql method + * DbFactoryService.cs, Codons/DbFactoryCodon.cs: added some error handling + +2007-07-14 Ben Motmans <ben.motmans@gmail.com> + + * ConnectionPool/*.cs: connection pool implementation, this replaces the default ADO.net + Pooling=true parameter and allows more control over pooled connections + * Providers/IConnectionProvider.cs: splitted in IConnectionProvider and IPooledDbConnection + * IDbFactory.cs: updated to reflect the new API + + +2007-07-10 Ben Motmans <ben.motmans@gmail.com> + + * Providers/IConnectionProvider.cs, Providers/AbstractConnectionProvider.cs: + added IsConnectionError property + Async query methods now have a state parameter + * Providers/ConnectionContext.cs, Providers/ConnectionSettings.cs: merged the + ConnectionContext properties inside the ConnectionSettings class + * ConnectionSettingsService.cs: Service to store all ConnectionSettings data + * DbFactoryService.cs: small fix, use the factory identifier instead of the codon identifier + * Dialect/Clauses/FromTableClause.cs: IdentifierExpression can be Aliased but doesn't have to + +2007-07-09 Ben Motmans <ben.motmans@gmail.com> + + * Schema/ViewSchema.cs: Added Columns property + +2007-07-05 Ben Motmans <ben.motmans@gmail.com> + + * Dialect/*: Object model for all Sql statements, clauses, expressions and literals + * IDbFactory.cs: SqlDialect property to specify the dialect used by the database provider + * DbFactoryService.cs: static class design instead of monodevelop service + * Providers/ConnectionContext.cs: container class for ConnectionSettings with corresponding providers + * Providers/IConnectionProvider.cs, Providers/AbstractConnectionProvider.cs,: added and implemented + ExecuteQuery* and ExecuteQuery*Async methods + +2007-07-02 Ben Motmans <ben.motmans@gmail.com> + + * Providers/ISchemaProvider.cs: + * Providers/AbstractSchemaProvider.cs: + removed table,view and procedure Get*Definition methods and integrated them in GetTable, GetView and GetProcedure + + * Providers/IDbFactory.cs: + Added Identifier property + Added GetDefaultConnectionSettings property + + * Schema/*: fixed small compilation issues + +2007-07-01 Ben Motmans <ben.motmans@gmail.com> + + * Providers/IDbFactory.cs: Factory class to be implemented by each database provider + * Codons/DbFactoryCodon.cs: Codon for IDbFactory extensions + * Providers/DbFactoryService.cs: Service point for DbFactory codons + * Schema/*: added TODO items + +2007-06-27 Ben Motmans <ben.motmans@gmail.com> + + * Schema/*.cs: constructor with SchemaProvider parameter + * Schema/*.cs: use of generic collections instead of arrays + * Providers/ConnectionSettings.cs: database property + +2007-06-27 Ben Motmans <ben.motmans@gmail.com> + + * Providers/AbstractConnectionProvider.cs: abstract connection provider + +2007-06-26 Ben Motmans <ben.motmans@gmail.com> + + * Schema/DataTypeCategory.cs, Schema/DataTypeSchema.cs: added an enumeration to specify the category + of the data type, this can be used in the future for data migration + +2007-06-25 Ben Motmans <ben.motmans@gmail.com> + + * Schema/TableSchema.cs, Schema/ViewSchema.cs, Schema/ProcedureSchema.cs, Schema/ColumnsSchema.cs, + Schema/ConstraintSchema.cs: lazy loaded columns, parameters, definition, ... parameters + * Schema/Range.cs, Schema/DataTypeSchema.cs: length, precision and scale range properties + +2007-06-24 Ben Motmans <ben.motmans@gmail.com> + + * Creation of designer, visualisation and query sub-projects + * Providers/ConnectionSettings.cs: class to seperate connection settings from the connection provider + +2007-06-23 Ben Motmans <ben.motmans@gmail.com> + + * Providers/IDbProvider.cs: splitted into Providers/ISchemaProvider.cs and Providers/IConnectionProvider.cs + * Providers/ISchemaProvider.cs: Use of generics where possible and logic + * Providers/ISchemaProvider.cs: Added GetDatabases method + +2007-06-22 Ben Motmans <ben.motmans@gmail.com> + + * Imported code from MonoQuery + +2007-06-01 Jeffrey Stedfast <fejj@novell.com> + + * Mono.Data.Sql/Makefile.am: Only build the supported database + providers (based on configure results). + +2007-05-11 Lluis Sanchez Gual <lluis@novell.com> + + * MonoQuery/MonoQuery.mdp: Copy the .addins.xml file to the output dir. + +2007-05-11 Lluis Sanchez Gual <lluis@novell.com> + + * Mono.Data.Sql/Makefile.am, Mono.Data.Sql/Mono.Data.Sql.mdp, + MonoQuery/Makefile.am, MonoQuery/MonoQuery.mdp: Fixed. + +2007-05-10 Lluis Sanchez Gual <lluis@novell.com> + + * Mono.Data.Sql/Makefile.am, Mono.Data.Sql/Mono.Data.Sql.mdp, + MonoQuery/Makefile.am, MonoQuery/MonoQuery.mdp: Fix build. + +2007-05-09 Lluis Sanchez Gual <lluis@novell.com> + + * Mono.Data.Sql/Makefile.am, Mono.Data.Sql/Mono.Data.Sql.mdp: Reference + shared assemblies from the correct location. Added missing assembly + reference. + * MonoQuery/Makefile.am, MonoQuery/MonoQuery.mdp: Reference shared + assemblies from the correct location. + +2007-05-04 Lluis Sanchez Gual <lluis@novell.com> + + * MonoQuery/Makefile.am, MonoQuery/MonoQuery.addin.xml, + MonoQuery/MonoQuery.mdp: Migration to Mono.Addins. + +2007-04-19 Lluis Sanchez Gual <lluis@novell.com> + + * tests/Mono.Data.Sql.Tests.mdp, Mono.Data.Sql/Mono.Data.Sql.mdp, + MonoQuery/MonoQuery.mdp: Don't copy referenced assemblies. + +2007-02-22 Atsushi Enomoto <atsushi@ximian.com> + + * Mono.Data.Sql/Providers/NpgsqlDbProvider.cs : pgsql somehow + returns user ID as int64 while it should be int32, so using + GetValue() here. + +2007-02-20 Ankit Jain <jankit@novell.com> + + * MonoQuery/Commands/Commands.cs (Run): Handle empty connection string. + Destroy the dialog even if an exception is thrown. + +2007-02-16 Lluis Sanchez Gual <lluis@novell.com> + + * MonoQuery/MonoQuery.addin.xml: Change add-in versions to 0.13. + +2007-02-15 Lluis Sanchez Gual <lluis@novell.com> + + * Mono.Data.Sql.mds, tests/Mono.Data.Sql.Tests.mdp, + Mono.Data.Sql/Makefile.am, Mono.Data.Sql/Mono.Data.Sql.mdp, + MonoQuery/Makefile.am, MonoQuery/MonoQuery.mdp: Synchronized the MD + project and the Makefile + +2007-02-06 David Makovský (Yakeen) <yakeen@sannyas-on.net> + + * MonoQuery/MonoQuery.addin.xml: added translatable string for SQL definition pad + +2006-12-17 Lluis Sanchez Gual <lluis@novell.com> + + * MonoQuery/MonoQueryService.cs: Use the FileService for copying and + deleting files. + +2006-09-18 Jacob Ilsø Christensen <jacobilsoe@gmail.com> + + * Mono.Data.Sql.mds: + * tests/Mono.Data.Sql.Tests.mdp: + * Mono.Data.Sql/Mono.Data.Sql.mdp: + * MonoQuery/MonoQuery.mdp: + Updated. + +2006-09-15 Jimmy <jkernel1234@bellsouth.net> + + * Mono.Data.Sql/Providers/SqliteDbProvider.cs: + Fix to not show indices in table view. + +2006-08-31 Levi Bard <taktaktaktaktaktaktaktaktaktak@gmail.com> + + * MonoQuery/MonoQueryService.cs: File existence check on unload. + +2006-08-08 Jacob Ilsø Christensen <jacobilsoe@gmail.com> + + * Mono.Data.Sql/Makefile.am: + * MonoQuery/Makefile.am: + Added support for enabling/disabling MonoQuery. + +2006-07-03 Lluis Sanchez Gual <lluis@novell.com> + + * MonoQuery/MonoQuery.addin.xml: Updated references. + +2006-05-04 Lluis Sanchez Gual <lluis@novell.com> + + * Mono.Data.Sql.mds: Updated. + * tests/Mono.Data.Sql.Tests.mdp: Updated. + * Mono.Data.Sql/Mono.Data.Sql.mdp: Updated. + * MonoQuery/MonoQuery.mdp: Updated. + +2006-03-30 Lluis Sanchez Gual <lluis@novell.com> + + * MonoQuery/MonoQuery.addin.xml: Updated references. + +2006-03-24 Lluis Sanchez Gual <lluis@novell.com> + + * Mono.Data.Sql/Mono.Data.Sql.mdp: + * MonoQuery/MonoQuery.mdp: + * MonoQuery/Makefile.am: + * Mono.Data.Sql/Makefile.am: Use an unified format. + Patch by Matze Braun. + + * MonoQuery/MonoQuery.addin.xml: Updated add-in versions. + +2006-02-24 Lluis Sanchez Gual <lluis@novell.com> + + * MonoQuery/MonoQuery/MonoQuery.mdp: Updated references. + +2006-02-23 Daniel Morgan <danielmorgan@verizon.net> + + * TODO: add ToDo file for MonoQuery and Mono.Data.Sql + +2006-02-22 Daniel Morgan <danielmorgan@verizon.net> + + * Mono.Data.Sql/Makefile.Win32: added file to build + Mono.Data.Sql on Win32 without autotools + +2006-01-14 Andrés G. Aragoneses <knocte@gmail.com> + + * MonoQuery/Gui/SqlQueryView.cs: Fixed a typo. + +2005-11-04 Lluis Sanchez Gual <lluis@novell.com> + + * MonoQuery/Gui/SqlDefinitionPad.cs: Fix gtksourceview warning. + +2005-10-11 Lluis Sanchez Gual <lluis@novell.com> + + * MonoQuery/MonoQuery.addin.xml: Fixed addin header information. + Use "id" attribuet instead of "name" to identify addins. + +2005-10-04 Lluis Sanchez Gual <lluis@novell.com> + + * MonoQuery/MonoQuery.addin.xml: Added addin dependencies. + +2005-09-27 Christian Hergert <christian.hergert@gmail.com> + + * Mono.Data.Sql/Providers/SqliteDbProvider.cs: Add ankit's sqlite + updates. + +2005-09-23 Christian Hergert <christian.hergert@gmail.com> + + * Update svn:ignore + +2005-09-22 Christian Hergert <christian.hergert@gmail.com> + + * Mono.Data.Sql/Providers/NpgsqlDbProvider.cs: Encapsulate GetDateTime + method in a try catch. + +2005-09-05 Sureshkumar T <tsureshkumar@novell.com> + + * Mono.Data.Sql/Providers/SqlDbProvider.cs: implemented procedure + and their parameters listing. + +2005-08-25 Daniel Morgan <danielmorgan@verizon.net> + + * Extras/MonoQuery/MonoQuery/Gui/SqlQueryView.cs: implement + execution of SQL statements in different modes: if text + selected then execute as-is, execute one statement starting at + cursor, and execute multiple statements one-at-a-time starting + at cursor + + * Mono.Data.Sql/Providers/OracleDbProvider.cs: only show + what can be browsed + + * Extras/MonoQuery/Mono.Data.Sql/Providers/SqlDbProvider.cs: add + ColumnSchema and remove others not used. Remove constraints since + they are not working + + * Extras/MonoQuery/Mono.Data.Sql/Providers/SybaseDbProvider.cs: add + ColumnSchema and remove others not used. + +2005-08-22 Daniel Morgan <danielmorgan@verizon.net> + + * Mono.Data.Sql/Providers/OracleDbProvider.cs: fix ExecuteSQL + +2005-08-21 Christian Hergert <christian.hergert@gmail.com> + + * MonoQuery/Commands/Commands.cs: Add some new commands to the enum + * MonoQuery/Gui/NodeBuilders/DatabaseNodeBuilder.cs: Use new icons + * MonoQuery/Gui/NodeBuilders/ProviderCollectionNodeBuilder.cs: Use new + icon. + * MonoQuery/Gui/NodeBuilders/TablesNodeBuilder.cs: Add new commands + for refresh and show query tool. + * MonoQuery/Gui/NodeBuilders/TableNodeBuilder.cs: Add new + commands for empty, drop, refresh, and show query tool. + * MonoQuery/Gui/NodeBuilders/ColumnNodeBuilder.cs: Build icons + reflective of the columns datatype. + * MonoQuery/Gui/FakeNodes.cs: add refresh to the fake tables node. + This way the builder can subscribe and rebuild the tree. Probably can + be done in a better way. + * MonoQuery/Gui/SqlQueryView.cs: new query tool + * MonoQuery/Makefile.am: updated + * MonoQuery/icons/MonoQuery.Stop: New icon for query tool + * MonoQuery/icons/MonoQuery.RunFromCursor: New icon for query tool + * MonoQuery/icons/MonoQuery.Explain: New icon for query tool + * MonoQuery/icons/MonoQuery.Param: New icon for procedure parameters. + * MonoQuery/icons/MonoQuery.Numeric: new icon for numeric data type. + * MonoQuery/icons/MonoQuery.Execute: New icon for query tool + * MonoQuery/icons/MonoQuery.Database.Connected: Database connected + icon + * MonoQuery/icons/MonoQuery.Database.Disconnected: Database error on + connection icon. + * MonoQuery/icons/MonoQuery.String: String data type icon + * MonoQuery/icons/MonoQuery.Providers: New providers icon + * MonoQuery/icons/MonoQuery.Blob: Blob|byte[] data type icon + * MonoQuery/icons/MonoQuery.SqlQueryView: Query view icon + * MonoQuery/MonoQuery.addin.xml: Updated with new context menus and + icons. + * MonoQuery/MonoQuery.mdp: Updated + * Mono.Data.Sql/Providers/DbProviderBase.cs: Add explain support. + * Mono.Data.Sql/Providers/SqlDbProvider.cs: Catch errors for async + mode and return null. + * Mono.Data.Sql/Providers/NpgsqlDbProvider.cs: + * Mono.Data.Sql/Providers/OracleDbProvider.cs: + * Mono.Data.Sql/Providers/MySqlDbProvider.cs: + * Mono.Data.Sql/Providers/FirebirdDbProvider.cs: + * Mono.Data.Sql/Providers/SybaseDbProvider.cs: + * Mono.Data.Sql/Providers/OdbcDbProvider.cs: + +2005-08-20 Christian Hergert <christian.hergert@gmail.com> + + * tests/test-oracle-1.cs: Test. Will be converted to nunit later. + * tests/test-firebird-1.cs: + * tests/test-sybase-1.cs: + * MonoQuery/Gui/NodeBuilders/TableNodeBuilder.cs: Do not append the + sql statement with `;' as this breaks oracle. + * MonoQuery/monoquery.glade: Make password hidden by default. + Passwords can be still seen in advanced textview. this is ok and done + on purpose. + * MonoQuery/MonoQuery.mdp: Updated + * Mono.Data.Sql/Makefile.am: + * Mono.Data.Sql/Providers/FirebirdDbProvider.cs: New firebird + provider. + * Mono.Data.Sql/Providers/SybaseDbProvider.cs: New sybase provider + * Mono.Data.Sql/Providers/OdbcDbProvider.cs: New generic odbc + connector. + * Mono.Data.Sql/Mono.Data.Sql.mdp: Updated + +2005-08-12 Lluis Sanchez Gual <lluis@novell.com> + + * MonoQuery/Makefile.am: embed icons as resources. + * MonoQuery/MonoQuery.addin.xml: Register new stock icons. + +2005-08-06 Christian Hergert <christian.hergert@gmail.com> + + * Mono.Data.Sql/AssemblyInfo.cs: Fix versioning stuff + * Mono.Data.Sql/Providers/NpgsqlDbProvider.cs: Update supported types. + properly close data readers. + * Mono.Data.Sql/Providers/MySqlDbProvider.cs: Add basic support for + tables, their columns, and users. This should be somewhat useful now. Need + to still determine which versions of mysql ByteFX driver works with. + * MonoQuery/AssemblyInfo.cs: Fix versioning stuff + * MonoQuery/Gui/NodeBuilders/TableNodeBuilder.cs: Update to check that the + type is supported before showing a dummy node. + * MonoQuery/Gui/ConnectionDialog.cs: Change Secret to Password. + +2005-08-06 Christian Hergert <christian.hergert@gmail.com> + + * Mono.Data.Sql.mds: Updated + * Mono.Data.Sql/Schema/ForeignKeyConstraintSchema.cs: Add setter for + reference table name. + * Mono.Data.Sql/Schema/UniqueConstraintSchema.cs: Add default Constructor. + * Mono.Data.Sql/Makefile.am: Updated to build when files change. + * Mono.Data.Sql/Providers/NpgsqlDbProvider.cs: Add some more guts to the + Constraint builders for tables. + * MonoQuery/Gui/NodeBuilders/ConstraintNodeBuilder.cs: Add a handler + * MonoQuery/MonoQuery.addin.xml: Load mono.data.sql. + +2005-08-06 Christian Hergert <christian.hergert@gmail.com> + + * tests/Mono.Data.Sql.Tests.mdp: Updated + * Mono.Data.Sql/Schema/AbstractSchema.cs: Add Options hashtable for + generic extra options above and beyond the hardcoded properties. + * Mono.Data.Sql/Schema/UserSchema.cs: Add a few new descriptor objects. + * Mono.Data.Sql/Providers/NpgsqlDbProvider.cs: Add GetUser () : + UserSchema[] support. + * Mono.Data.Sql/Mono.Data.Sql.mdp: Updated + * MonoQuery/Gui/NodeBuilders/UsersNodeBuilder.cs: Build the underlying + users. + * MonoQuery/Gui/NodeBuilders/UserNodeBuilder.cs: New builder to build a + user object in the tree. + * MonoQuery/Gui/DbProviderCollection.cs: Add some more xml includes for + the database persistence file. + * MonoQuery/Makefile.am: Updated + * MonoQuery/MonoQuery.addin.xml: Updated + * MonoQuery/MonoQuery.mdp: Updated + +2005-08-08 John Luke <john.luke@gmail.com> + + * MonoQuery/Makefile.am: add glade file to EXTRA_DIST to + fix distcheck + +2005-08-06 Christian Hergert <christian.hergert@gmail.com> + + * MonoQuery/Makefile.in: should not have been imported. + * MonoQuery/Makefile: should not have been imported. + +2005-08-03 Lluis Sanchez Gual <lluis@novell.com> + + * MonoQuery/Commands/Commands.cs: + * MonoQuery/Gui/NodeBuilders/DatabaseNodeBuilder.cs: + * MonoQuery/Gui/DatabasePad.cs: Moved command handlers to node builders. + +2005-08-02 Christian Hergert <christian.hergert@gmail.com> + + * MonoQuery.prjx: deleted + * MonoQuery.addin.xml.in: removed + * Exceptions: removed + * Services: removed + * Gui: removed + * Codons: removed + * SchemaClass: removed + * MonoQuery.cmbx: removed + * Collection: removed + * MonoQueryView.cs: removed + * MonoQuery/AssemblyInfo.cs: part of monoquery2 + * MonoQuery/MonoQuery.mds: + * MonoQuery/Commands: + * MonoQuery/Commands/Commands.cs: + * MonoQuery/Makefile.in: + * MonoQuery/MonoQueryService.cs: + * MonoQuery/Gui/NodeBuilders/UsersNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/ParametersNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/DatabaseNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/TypesNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/LanguagesNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/ProviderCollectionNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/ConstraintsNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/AggregatesNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/TablesNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/ViewNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/ProceduresNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/OperatorsNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/GroupsNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/ColumnsNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/RolesNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/ConstraintNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/TriggersNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/TableNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/ProcedureNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/RulesNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/SequencesNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/ColumnNodeBuilder.cs: + * MonoQuery/Gui/NodeBuilders/ViewsNodeBuilder.cs: + * MonoQuery/Gui/DbProviderCollection.cs: + * MonoQuery/Gui/SqlDefinitionPad.cs: + * MonoQuery/Gui/ConnectionDialog.cs: + * MonoQuery/Gui/FakeNodes.cs: + * MonoQuery/Gui/DatabasePad.cs: + * MonoQuery/Gui/DataGridView.cs: + * MonoQuery/monoquery.glade: + * MonoQuery/Makefile.am: + * MonoQuery/MonoQuery.addin.xml: + * MonoQuery/Makefile: + * MonoQuery/MonoQuery.mdp: + * AssemblyInfo.cs: removed + * Mono.Data.Sql.mds: removed + * Commands: removed + * tests/NpgsqlTablesTest.cs: start of tests for monoquery2. these dont + really do anything at the moment + * tests/pgsql.sql + * tests/CreateProviderTests.cs + * tests/Mono.Data.Sql.Tests.mdp + * MonoQuery.mdsx: removed + * Makefile.am: updated + * Mono.Data.Sql/AssemblyInfo.cs: core to monoquery2 + * Mono.Data.Sql/Schema: + * Mono.Data.Sql/Schema/OperatorSchema.cs: + * Mono.Data.Sql/Schema/GroupSchema.cs: + * Mono.Data.Sql/Schema/ColumnSchema.cs: + * Mono.Data.Sql/Schema/SchemaSchema.cs: + * Mono.Data.Sql/Schema/RoleSchema.cs: + * Mono.Data.Sql/Schema/PrimaryKeyConstraintSchema.cs: + * Mono.Data.Sql/Schema/AbstractSchema.cs: + * Mono.Data.Sql/Schema/TriggerSchema.cs: + * Mono.Data.Sql/Schema/RuleSchema.cs: + * Mono.Data.Sql/Schema/ForeignKeyConstraintSchema.cs: + * Mono.Data.Sql/Schema/SequenceSchema.cs: + * Mono.Data.Sql/Schema/ViewSchema.cs: + * Mono.Data.Sql/Schema/UniqueConstraintSchema.cs: + * Mono.Data.Sql/Schema/DataTypeSchema.cs: + * Mono.Data.Sql/Schema/IndexConstraintSchema.cs: + * Mono.Data.Sql/Schema/UserSchema.cs: + * Mono.Data.Sql/Schema/ParameterSchema.cs: + * Mono.Data.Sql/Schema/CheckConstraintSchema.cs: + * Mono.Data.Sql/Schema/LanguageSchema.cs: + * Mono.Data.Sql/Schema/ConstraintSchema.cs: + * Mono.Data.Sql/Schema/PrivilegeSchema.cs: + * Mono.Data.Sql/Schema/AggregateSchema.cs: + * Mono.Data.Sql/Schema/TableSchema.cs: + * Mono.Data.Sql/Schema/ISchema.cs: + * Mono.Data.Sql/Schema/ProcedureSchema.cs: + * Mono.Data.Sql/Makefile.am: + * Mono.Data.Sql/Providers: + * Mono.Data.Sql/Providers/DbProviderBase.cs: + * Mono.Data.Sql/Providers/SqlDbProvider.cs: + * Mono.Data.Sql/Providers/SqliteDbProvider.cs: + * Mono.Data.Sql/Providers/NpgsqlDbProvider.cs: + * Mono.Data.Sql/Providers/MySqlDbProvider.cs: + * Mono.Data.Sql/Providers/OracleDbProvider.cs: + * Mono.Data.Sql/Mono.Data.Sql.mdp: + +2005-07-13 Lluis Sanchez Gual <lluis@novell.com> + + * MonoQueryView.cs: + * Gui/DataView/MonoQueryDataView.cs: Pads are now responsible + of showing its own widgets. + +2005-03-31 Christian Hergert <chris@mosaix.net> + + * MonoQueryView.cs: Fix the momento icon. + +2005-03-14 Lluis Sanchez Gual <lluis@novell.com> + + * MonoQuery.addin.xml.in: Define the MonoQuery pad. + +2005-03-06 Christian Hergert <chris@mosaix.net> + + * MonoQuery/Makefile.am: EXTRA_DIST doesnt support conditional variables. + +2005-02-02 Christian Hergert <chris@mosaix.net> + + * MonoQuery/MonoQuery.addin.xml: Moved to .in to be autogenerated + by automake. + +2005-02-02 Christian Hergert <chris@mosaix.net> + + * Extras/MonoQuery/Gui/SqlQueryView/SqlQueryView.cs: flush + +2005-01-31 Christian Hergert <chris@mosaix.net> + + * Extras/MonoQuery/Gui/SqlQueryView/SqlQueryView.cs: Updated to new + ToolItem to fix compiler warning. + +2005-01-26 Christian Hergert <chris@mosaix.net> + + * Extras/MonoQuery/Gui/Abstract/AbstractMonoQueryNode.cs: + * Extras/MonoQuery/Commands/MonoQueryCommands.cs: Fixed to use new + ShowView + +2005-01-08 Christian Hergert <chris@mosaix.net> + + * Fixed druid to expand the connection after building + +2005-01-08 Christian Hergert <chris@mosaix.net> + + * Following Makefile.am fixes + * Copy .addin.xml if it changes + * Fix setup to work if layout changes in the future + * If .addin.xml changes, only copy addin and not rebuild the dll + * Get package references from configure rather than statically + * Added files with GetString to the PO .in file + * Fixed a few warnings from build stage + +2005-01-06 Christian Hergert <chris@mosaix.net> + + * Initial creation of MonoQuery AddIn diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Codons/ActionCodon.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Codons/ActionCodon.cs new file mode 100644 index 0000000000..dd66a5e55a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Codons/ActionCodon.cs @@ -0,0 +1,60 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Sql +{ + [ExtensionNode (Description="The list of supported actions for each database object.")] + public class ActionCodon : ExtensionNode + { + [NodeAttribute("category", true, "The database object category, eg: Table.")] + string category = null; + + [NodeAttribute("flags", true, "Comma seperated list of SchemaAction flags.")] + string flags = null; + + private SchemaActions actions; + + public string Category { + get { return category; } + } + + public SchemaActions Actions { + get { return actions; } + } + + protected override void Read (NodeElement elem) + { + base.Read (elem); + + actions = (SchemaActions)Enum.Parse (typeof (SchemaActions), flags); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Codons/CapabilitiesCodon.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Codons/CapabilitiesCodon.cs new file mode 100644 index 0000000000..70253717ba --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Codons/CapabilitiesCodon.cs @@ -0,0 +1,69 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Sql +{ + [ExtensionNode (Description="The list of supported flags for each database object.")] + public class CapabilitiesCodon : ExtensionNode + { + [NodeAttribute("category", true, "The database object category, eg: Table.")] + string category = null; + + [NodeAttribute("action", true, "The database operation for which the flags are valid, eg: Create.")] + string action = null; + + [NodeAttribute("flags", true, "Comma seperated list of SchemaAction flags.")] + string flags = null; + + private SchemaActions actions; + private int parsedFlags; + + public string Category { + get { return category; } + } + + public SchemaActions Actions { + get { return actions; } + } + + public int ParsedFlags { + get { return parsedFlags; } + } + + protected override void Read (NodeElement elem) + { + base.Read (elem); + + actions = (SchemaActions)Enum.Parse (typeof (SchemaActions), action); + parsedFlags = CapabilitiesUtility.Parse (category, flags); + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Codons/CapabilityFlagsCodon.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Codons/CapabilityFlagsCodon.cs new file mode 100644 index 0000000000..f95892e323 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Codons/CapabilityFlagsCodon.cs @@ -0,0 +1,51 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Sql +{ + [ExtensionNode (Description="The list of supported actions for each database object.")] + public class CapabilityFlagsCodon : ExtensionNode + { + [NodeAttribute("category", true, "The database object category, eg: Table.")] + string category = null; + + [NodeAttribute("class", true, "The type of the enumeration.")] + string cls = null; + + public string Category { + get { return category; } + } + + public Type Type { + get { return Addin.GetType (cls, true); } + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Codons/DbFactoryCodon.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Codons/DbFactoryCodon.cs new file mode 100644 index 0000000000..2244c65aad --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Codons/DbFactoryCodon.cs @@ -0,0 +1,63 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Sql +{ + public class DbFactoryCodon : TypeExtensionNode + { + private void BuildChildren (IDbFactory fac) + { + foreach (ExtensionNode node in ChildNodes) { + ActionCodon actionCodon = node as ActionCodon; + if (actionCodon != null) { + fac.SetSupportedActions (actionCodon.Category, actionCodon.Actions); + } else { + CapabilitiesCodon capabilitiesCodon = node as CapabilitiesCodon; + if (capabilitiesCodon != null) + fac.SetCapabilities (capabilitiesCodon.Category, capabilitiesCodon.Actions, capabilitiesCodon.ParsedFlags); + } + } + } + + public IDbFactory DbFactory { + get { + try { + IDbFactory fac = (IDbFactory)base.CreateInstance (); + BuildChildren (fac); + return fac; + } catch (Exception e) { + LoggingService.LogError (e.ToString ()); + return null; + } + } + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/ColumnSchemaCollection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/ColumnSchemaCollection.cs new file mode 100644 index 0000000000..0f3b451792 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/ColumnSchemaCollection.cs @@ -0,0 +1,44 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public sealed class ColumnSchemaCollection : SortedCollectionBase<ColumnSchema> + { + public ColumnSchemaCollection () + : base (false) //not sorted, column order is important + { + } + + public ColumnSchemaCollection (ColumnSchemaCollection collection) + : base (collection, false) + { + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/ConstraintSchemaCollection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/ConstraintSchemaCollection.cs new file mode 100644 index 0000000000..5703d31003 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/ConstraintSchemaCollection.cs @@ -0,0 +1,72 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public sealed class ConstraintSchemaCollection : SortedCollectionBase<ConstraintSchema> + { + public ConstraintSchemaCollection () + : base (true) + { + } + + public ConstraintSchemaCollection (ConstraintSchemaCollection collection) + : base (collection, true) + { + } + + public ConstraintSchema GetConstraint (ConstraintType type) + { + foreach (ConstraintSchema item in List) { + if (item.ConstraintType == type) + return item; + } + return null; + } + + public IEnumerable<ConstraintSchema> GetConstraints (ConstraintType type) + { + foreach (ConstraintSchema item in List) { + if (item.ConstraintType == type) + yield return item; + } + } + + public ConstraintSchema GetConstraintWithColumn (string columnName) + { + foreach (ConstraintSchema item in List) { + foreach (ColumnSchema column in item.Columns) { + if (column.Name == columnName) + return item; + } + } + return null; + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/DataTypeSchemaCollection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/DataTypeSchemaCollection.cs new file mode 100644 index 0000000000..086edaf61c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/DataTypeSchemaCollection.cs @@ -0,0 +1,44 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public sealed class DataTypeSchemaCollection : SortedCollectionBase<DataTypeSchema> + { + public DataTypeSchemaCollection () + : base (true) + { + } + + public DataTypeSchemaCollection (DataTypeSchemaCollection collection) + : base (collection, true) + { + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/DatabaseSchemaCollection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/DatabaseSchemaCollection.cs new file mode 100644 index 0000000000..34fd0bc5c6 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/DatabaseSchemaCollection.cs @@ -0,0 +1,44 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public sealed class DatabaseSchemaCollection : SortedCollectionBase<DatabaseSchema> + { + public DatabaseSchemaCollection () + : base (true) + { + } + + public DatabaseSchemaCollection (DatabaseSchemaCollection collection) + : base (collection, true) + { + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/IPropertyComparer.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/IPropertyComparer.cs new file mode 100644 index 0000000000..badbd2c592 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/IPropertyComparer.cs @@ -0,0 +1,36 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public interface IPropertyComparer<T, U> + { + int Compare (T x, U y); + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/IndexSchemaCollection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/IndexSchemaCollection.cs new file mode 100644 index 0000000000..f196430ddf --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/IndexSchemaCollection.cs @@ -0,0 +1,44 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public sealed class IndexSchemaCollection : SortedCollectionBase<IndexSchema> + { + public IndexSchemaCollection () + : base (true) + { + } + + public IndexSchemaCollection (IndexSchemaCollection collection) + : base (collection, true) + { + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/ParameterSchemaCollection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/ParameterSchemaCollection.cs new file mode 100644 index 0000000000..7f9cea0fad --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/ParameterSchemaCollection.cs @@ -0,0 +1,44 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public sealed class ParameterSchemaCollection : SortedCollectionBase<ParameterSchema> + { + public ParameterSchemaCollection () + : base (false) //not sorted, parameter order is important + { + } + + public ParameterSchemaCollection (ParameterSchemaCollection collection) + : base (collection, false) + { + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/ProcedureSchemaCollection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/ProcedureSchemaCollection.cs new file mode 100644 index 0000000000..dcdc619390 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/ProcedureSchemaCollection.cs @@ -0,0 +1,44 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public sealed class ProcedureSchemaCollection : SortedCollectionBase<ProcedureSchema> + { + public ProcedureSchemaCollection () + : base (true) + { + } + + public ProcedureSchemaCollection (ProcedureSchemaCollection collection) + : base (collection, true) + { + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/SortedCollectionBase.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/SortedCollectionBase.cs new file mode 100644 index 0000000000..aab734519a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/SortedCollectionBase.cs @@ -0,0 +1,299 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public abstract class SortedCollectionBase<T> : CollectionBase, IEnumerable<T>, IPropertyComparer<T, string> where T : ISchema + { + public SortedCollectionItemEventHandler<T> ItemAdded; + public SortedCollectionItemEventHandler<T> ItemRemoved; + + protected bool sort = false; + + protected SortedCollectionBase (bool sort) + { + this.sort = sort; + } + + protected SortedCollectionBase (SortedCollectionBase<T> collection, bool sort) + : this (sort) + { + if (collection == null) + return; + + foreach (T item in collection) + Add ((T)item.Clone ()); + } + + public T this [int index] { + get { return (T)List[index]; } + set { List[index] = value; } + } + + public bool IsSorted { + get { return sort; } + set { + if (sort != value) { + sort = value; + if (value) + Sort (); + } + } + } + + public int Add (T item) + { + if (item == null) + throw new ArgumentNullException ("item"); + + int index = -1; + if (sort) + index = SortedInsert (item); + else + index = List.Add (item); + + if (ItemAdded != null) + ItemAdded (this, new SortedCollectionItemEventArgs<T> (item)); + + return index; + } + + public int IndexOf (T item) + { + if (item == null) + throw new ArgumentNullException ("item"); + + return List.IndexOf (item); + } + + public void Insert (int index, T item) + { + if (item == null) + throw new ArgumentNullException ("item"); + + if (sort) + throw new InvalidOperationException ("Insert can only be used in an unsorted collection."); + + List.Insert (index, item); + + if (ItemAdded != null) + ItemAdded (this, new SortedCollectionItemEventArgs<T> (item)); + } + + public void Remove (T item) + { + if (item == null) + throw new ArgumentNullException ("item"); + + List.Remove (item); + + if (ItemRemoved != null) + ItemRemoved (this, new SortedCollectionItemEventArgs<T> (item)); + } + + public bool Contains (T item) + { + if (item == null) + throw new ArgumentNullException ("item"); + + return List.Contains (item); + } + + public bool Contains (string name) + { + if (name == null) + throw new ArgumentNullException ("name"); + + if (sort) + return BinarySearchIndex<string> (this, name) >= 0; + else + return SearchIndex<string> (this, name) >= 0; + } + + public T Search (string name) + { + if (name == null) + throw new ArgumentNullException ("name"); + + int index = -1; + if (sort) + index = BinarySearchIndex<string> (this, name); + else + index = SearchIndex<string> (this, name); + if (index >= 0) + return this[index]; + return default (T); + } + + public int SearchIndex (string name) + { + if (name == null) + throw new ArgumentNullException ("name"); + + if (sort) + return BinarySearchIndex<string> (this, name); + else + return SearchIndex<string> (this, name); + } + + public virtual void Sort () + { + if (List.Count <= 1) return; + + //quicksort + Sort (0, List.Count - 1); + } + + public virtual void Swap (T x, T y) + { + if (x == null) + throw new ArgumentNullException ("x"); + if (y == null) + throw new ArgumentNullException ("y"); + + int indexX = IndexOf (x); + int indexY = IndexOf (y); + + if (indexX < 0 || indexY < 0) + throw new ArgumentException ("Both items must be present in the collection."); + + Swap (indexX, indexY); + } + + public virtual void Swap (int left, int right) + { + object swap = List[left]; + List[left] = List[right]; + List[right] = swap; + } + + IEnumerator<T> IEnumerable<T>.GetEnumerator () + { + foreach (T item in List) + yield return item; + } + + protected virtual int SortedInsert (T item) + { + if (List.Count == 0) { + List.Add (item); + return 0; + } else { + int position = 0; + foreach (T t in List) { + if (Compare (item, t) < 0) + break; + position++; + } + if (position == List.Count) { + List.Add (item); + return List.Count - 1; + } else { + List.Insert (position, item); + return position; + } + } + } + + protected virtual void Sort (int lower, int upper) + { + if (lower < upper) { + int split = Pivot (lower, upper); + Sort (lower, split - 1); + Sort (split + 1, upper); + } + } + + protected virtual int Pivot (int lower, int upper) + { + int left = lower + 1; + T pivot = this[lower]; + int right = upper; + + while (left <= right) { + + while ((left <= right) && (Compare (this[left], pivot) <= 0)) + ++left; + + while ((left <= right) && (Compare (this[right], pivot) > 0)) + --right; + + if (left < right) { + Swap (left, right); + ++left; + --right; + } + } + + Swap (lower, right); + return right; + } + + protected virtual int BinarySearchIndex<U> (IPropertyComparer<T, U> comparer, U value) + { + int min = 0; + int max = List.Count - 1; + int cmp = 0; + + while (min <= max) { + int mid = (min + max) / 2; + cmp = comparer.Compare (this[mid], value); + + if (cmp == 0) + return mid; + else if (cmp > 0) + max = mid - 1; + else + min = mid + 1; // compensate for the rounding down + } + + return ~min; + } + + protected virtual int SearchIndex<U> (IPropertyComparer<T, U> comparer, U value) + { + int max = List.Count - 1; + for (int i=0; i<max; i++) + if (comparer.Compare (this[i], value) == 0) + return i; + return -1; + } + + protected virtual int Compare (T x, T y) + { + return 0; + } + + int IPropertyComparer<T, string>.Compare (T x, string y) + { + ISchema schema = (ISchema)x; + return schema.Name.CompareTo (y); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/SortedCollectionItemEventArgs.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/SortedCollectionItemEventArgs.cs new file mode 100644 index 0000000000..8dd6bd277b --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/SortedCollectionItemEventArgs.cs @@ -0,0 +1,47 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public delegate void SortedCollectionItemEventHandler<T> (object sender, SortedCollectionItemEventArgs<T> args); + + public class SortedCollectionItemEventArgs<T> : EventArgs + { + private T item; + + public SortedCollectionItemEventArgs (T item) + { + this.item = item; + } + + public T Item { + get { return item; } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/TableSchemaCollection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/TableSchemaCollection.cs new file mode 100644 index 0000000000..b5f01e7fd2 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/TableSchemaCollection.cs @@ -0,0 +1,44 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public sealed class TableSchemaCollection : SortedCollectionBase<TableSchema> + { + public TableSchemaCollection () + : base (true) + { + } + + public TableSchemaCollection (TableSchemaCollection collection) + : base (collection, true) + { + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/TriggerSchemaCollection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/TriggerSchemaCollection.cs new file mode 100644 index 0000000000..97f543b708 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/TriggerSchemaCollection.cs @@ -0,0 +1,44 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public sealed class TriggerSchemaCollection : SortedCollectionBase<TriggerSchema> + { + public TriggerSchemaCollection () + : base (true) + { + } + + public TriggerSchemaCollection (TriggerSchemaCollection collection) + : base (collection, true) + { + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/UserSchemaCollection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/UserSchemaCollection.cs new file mode 100644 index 0000000000..759132612a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/UserSchemaCollection.cs @@ -0,0 +1,44 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public sealed class UserSchemaCollection : SortedCollectionBase<UserSchema> + { + public UserSchemaCollection () + : base (true) + { + } + + public UserSchemaCollection (UserSchemaCollection collection) + : base (collection, true) + { + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/ViewSchemaCollection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/ViewSchemaCollection.cs new file mode 100644 index 0000000000..2a956ca82d --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Collections/ViewSchemaCollection.cs @@ -0,0 +1,44 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +//
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public sealed class ViewSchemaCollection : SortedCollectionBase<ViewSchema> + { + public ViewSchemaCollection () + : base (true) + { + } + + public ViewSchemaCollection (ViewSchemaCollection collection) + : base (collection, true) + { + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Configuration/DatabaseConnectionContext.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Configuration/DatabaseConnectionContext.cs new file mode 100644 index 0000000000..a7da2ef111 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Configuration/DatabaseConnectionContext.cs @@ -0,0 +1,102 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public sealed class DatabaseConnectionContext
+ { + public event EventHandler RefreshEvent; + + private bool temp; + private DatabaseConnectionSettings connectionSettings; + + private IConnectionPool connectionPool; + private ISchemaProvider schemaProvider; + + public DatabaseConnectionContext (DatabaseConnectionSettings connectionSettings) + : this (connectionSettings, false) + { + } + + public DatabaseConnectionContext (DatabaseConnectionSettings connectionSettings, bool temp) + { + if (connectionSettings == null) + throw new ArgumentNullException ("connectionSettings"); + + this.connectionSettings = connectionSettings; + this.temp = temp; + } + + //temp connection contexts are not shown in the database pad + public bool IsTemporary { + get { return temp; } + set { temp = false; } + } + + public IDbFactory DbFactory { + get { return DbFactoryService.GetDbFactory (connectionSettings.ProviderIdentifier); } + } + + public DatabaseConnectionSettings ConnectionSettings { + get { return connectionSettings; } + } +
+ public IConnectionPool ConnectionPool { + get { + if (connectionPool == null) + connectionPool = DbFactoryService.CreateConnectionPool (this); + return connectionPool; + } + } + + public bool HasConnectionPool { + get { return connectionPool != null; } + } + + public ISchemaProvider SchemaProvider { + get { + if (ConnectionPool != null) { + if (schemaProvider == null) + schemaProvider = DbFactoryService.CreateSchemaProvider (this, connectionPool); + return schemaProvider; + } + return null; + } + } + + public bool HasSchemaProvider { + get { return schemaProvider != null; } + } + + public void Refresh () + { + if (RefreshEvent != null) + RefreshEvent (this, EventArgs.Empty); + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Configuration/DatabaseConnectionContextCollection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Configuration/DatabaseConnectionContextCollection.cs new file mode 100644 index 0000000000..c05f35705e --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Configuration/DatabaseConnectionContextCollection.cs @@ -0,0 +1,103 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Collections; +using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class DatabaseConnectionContextCollection : IEnumerable<DatabaseConnectionContext>
+ { + public event EventHandler Changed; + private List<DatabaseConnectionContext> contexts; +
+ public DatabaseConnectionContextCollection () + { + contexts = new List<DatabaseConnectionContext> (); + } + + public DatabaseConnectionContext this[int index] { + get { return contexts[index]; } + } + + internal void Add (DatabaseConnectionContext item) + { + contexts.Add (item); + OnChanged (EventArgs.Empty); + } + + public int Count { + get { return contexts.Count; } + } + + public int IndexOf (DatabaseConnectionContext item) + { + return contexts.IndexOf (item); + } + + internal void Insert (int index, DatabaseConnectionContext item) + { + contexts.Insert (index, item); + OnChanged (EventArgs.Empty); + } + + internal void Remove (DatabaseConnectionContext item) + { + contexts.Remove (item); + OnChanged (EventArgs.Empty); + } + + public bool Contains (DatabaseConnectionContext item) + { + return contexts.Contains (item); + } + + public bool Contains (string name) + { + foreach (DatabaseConnectionContext context in this) { + if (context.ConnectionSettings.Name == name) + return true; + } + return false; + } + + public IEnumerator<DatabaseConnectionContext> GetEnumerator () + { + return contexts.GetEnumerator (); + } + + IEnumerator IEnumerable.GetEnumerator () + { + return (contexts as IEnumerable).GetEnumerator (); + } + + protected virtual void OnChanged (EventArgs e) + { + if (Changed != null ) + Changed (this, e); + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Configuration/DatabaseConnectionContextEventArgs.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Configuration/DatabaseConnectionContextEventArgs.cs new file mode 100644 index 0000000000..58d3504156 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Configuration/DatabaseConnectionContextEventArgs.cs @@ -0,0 +1,46 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{ + public delegate void DatabaseConnectionContextEventHandler (object sender, DatabaseConnectionContextEventArgs args); +
+ public class DatabaseConnectionContextEventArgs : EventArgs
+ {
+ protected DatabaseConnectionContext context; + + public DatabaseConnectionContextEventArgs (DatabaseConnectionContext context) + { + this.context = context; + } + + public DatabaseConnectionContext ConnectionContext { + get { return context; } + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Configuration/DatabaseConnectionSettings.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Configuration/DatabaseConnectionSettings.cs new file mode 100644 index 0000000000..88c17ff6d0 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Configuration/DatabaseConnectionSettings.cs @@ -0,0 +1,131 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ [Serializable]
+ public class DatabaseConnectionSettings
+ { + private string name;
+ private string providerIdentifier;
+
+ private string server;
+ private int port; +
+ private string database;
+ private string username;
+ private string password;
+ private bool savePassword; + + private int minPoolSize; + private int maxPoolSize;
+
+ private string connectionString;
+ private bool useConnectionString; + + public DatabaseConnectionSettings () + { + } + + public DatabaseConnectionSettings (DatabaseConnectionSettings copy) + { + name = copy.Name; + providerIdentifier = copy.ProviderIdentifier; + server = copy.Server; + port = copy.Port; + database = copy.Database; + username = copy.Username; + password = copy.Password; + savePassword = copy.SavePassword; + minPoolSize = copy.MinPoolSize; + maxPoolSize = copy.MaxPoolSize; + useConnectionString = copy.UseConnectionString; + connectionString = copy.ConnectionString; + } + + public string ProviderIdentifier {
+ get { return providerIdentifier; }
+ set { providerIdentifier = value; }
+ }
+
+ public string Name {
+ get { return name; }
+ set { name = value; }
+ }
+
+ public string Server {
+ get { return server; }
+ set { server = value; }
+ }
+
+ public int Port {
+ get { return port; }
+ set { port = value; }
+ }
+
+ public string Database {
+ get { return database; }
+ set { database = value; }
+ }
+
+ public string Username {
+ get { return username; }
+ set { username = value; }
+ }
+
+ public string Password {
+ get { return password; }
+ set { password = value; }
+ }
+
+ public bool SavePassword {
+ get { return savePassword; }
+ set { savePassword = value; }
+ } + + public int MinPoolSize {
+ get { return minPoolSize; }
+ set { minPoolSize = value; }
+ } + + public int MaxPoolSize {
+ get { return maxPoolSize; }
+ set { maxPoolSize = value; }
+ } +
+ public string ConnectionString {
+ get { return connectionString; }
+ set { connectionString = value; }
+ }
+
+ public bool UseConnectionString {
+ get { return useConnectionString; }
+ set { useConnectionString = value; }
+ }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Configuration/DatabaseConnectionSettingsCollection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Configuration/DatabaseConnectionSettingsCollection.cs new file mode 100644 index 0000000000..65de34265c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Configuration/DatabaseConnectionSettingsCollection.cs @@ -0,0 +1,89 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System; +using System.Xml.Serialization;
+using System.Collections; +using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ [Serializable]
+ public class DatabaseConnectionSettingsCollection : CollectionBase, IEnumerable<DatabaseConnectionSettings>
+ { + public event EventHandler Changed; +
+ public DatabaseConnectionSettingsCollection () + : base () + { + } + + public DatabaseConnectionSettings this[int index] { + get { return List[index] as DatabaseConnectionSettings; } + set { List[index] = value; } + } + + public int Add (DatabaseConnectionSettings item) + { + int retval = List.Add (item); + OnChanged (EventArgs.Empty); + return retval; + } + + public int IndexOf (DatabaseConnectionSettings item) + { + return List.IndexOf (item); + } + + public void Insert (int index, DatabaseConnectionSettings item) + { + List.Insert (index, item); + OnChanged (EventArgs.Empty); + } + + public void Remove (DatabaseConnectionSettings item) + { + List.Remove (item); + OnChanged (EventArgs.Empty); + } + + public bool Contains (DatabaseConnectionSettings item) + { + return List.Contains (item); + } + + IEnumerator<DatabaseConnectionSettings> IEnumerable<DatabaseConnectionSettings>.GetEnumerator () + { + foreach (DatabaseConnectionSettings cs in this) + yield return cs; + } + + protected virtual void OnChanged (EventArgs e) + { + if (Changed != null ) + Changed (this, e); + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionContextService.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionContextService.cs new file mode 100644 index 0000000000..a374c928cf --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionContextService.cs @@ -0,0 +1,165 @@ +// +// Authors: +// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2005 Christian Hergert
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using System; +using System.IO; +using System.Text; +using System.Xml.Serialization; +using System.Collections.Generic; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Sql +{ + public static class ConnectionContextService + { + public static event DatabaseConnectionContextEventHandler ConnectionContextAdded; + public static event DatabaseConnectionContextEventHandler ConnectionContextRemoved; + public static event DatabaseConnectionContextEventHandler ConnectionContextEdited; + public static event DatabaseConnectionContextEventHandler ConnectionContextRefreshed; + + private static DatabaseConnectionContextCollection contexts; + + private static string configFile = null; + + static ConnectionContextService () + { + configFile = Path.Combine (PropertyService.ConfigPath, "MonoDevelop.Database.ConnectionManager.xml"); + Initialize (configFile); + } + + public static DatabaseConnectionContextCollection DatabaseConnections { + get { return contexts; } + } + + public static DatabaseConnectionContext AddDatabaseConnectionContext (DatabaseConnectionSettings settings) + { + if (settings == null) + throw new ArgumentNullException ("settings"); + + DatabaseConnectionContext context = new DatabaseConnectionContext (settings); + AddDatabaseConnectionContext (context); + return context; + } + + public static void AddDatabaseConnectionContext (DatabaseConnectionContext context) + { + if (context == null) + throw new ArgumentNullException ("context"); + + if (!contexts.Contains (context)) { + contexts.Add (context); + Save (); + if (ConnectionContextAdded != null) + ConnectionContextAdded (null, new DatabaseConnectionContextEventArgs (context)); + } + } + + public static void RemoveDatabaseConnectionContext (DatabaseConnectionContext context) + { + if (context == null) + throw new ArgumentNullException ("context"); + + contexts.Remove (context); + Save (); + if (ConnectionContextRemoved != null) + ConnectionContextRemoved (null, new DatabaseConnectionContextEventArgs (context)); + } + + public static void EditDatabaseConnectionContext (DatabaseConnectionContext context) + { + if (context == null) + throw new ArgumentNullException ("context"); + + Save (); + if (ConnectionContextEdited != null) + ConnectionContextEdited (null, new DatabaseConnectionContextEventArgs (context)); + } + + internal static void Initialize (string configFile) + { + DatabaseConnectionSettingsCollection connections = null; + if (File.Exists (configFile)) { + try { + using (FileStream fs = File.OpenRead (configFile)) { + XmlSerializer serializer = new XmlSerializer (typeof (DatabaseConnectionSettingsCollection)); + connections = (DatabaseConnectionSettingsCollection) serializer.Deserialize (fs); + } + } catch { + LoggingService.LogError (GettextCatalog.GetString ("Unable to load stored SQL connection information.")); + File.Delete (configFile); + } + } + + contexts = new DatabaseConnectionContextCollection (); + if (connections != null) { + StringBuilder sb = new StringBuilder (); + foreach (DatabaseConnectionSettings settings in connections) { + IDbFactory fac = DbFactoryService.GetDbFactory (settings); + if (fac == null) { + sb.Append ("Error: unable to load database provider '"); + sb.Append (settings.ProviderIdentifier); + sb.Append ("' for connection '"); + sb.Append (settings.Name); + sb.Append ("'"); + sb.Append (Environment.NewLine); + continue; + } + + contexts.Add (new DatabaseConnectionContext (settings)); + } + + if (sb.Length > 0) { + Exception ex = new Exception (sb.ToString ()); + QueryService.RaiseException (ex); + } + } + } + + public static void Save () + { + //temporarily empty all passwords that don't need to be saved + Dictionary<DatabaseConnectionSettings, string> tmp = new Dictionary<DatabaseConnectionSettings,string> (); + DatabaseConnectionSettingsCollection collection = new DatabaseConnectionSettingsCollection (); + foreach (DatabaseConnectionContext context in contexts) { + if (!context.ConnectionSettings.SavePassword) { + tmp.Add (context.ConnectionSettings, context.ConnectionSettings.Password); + context.ConnectionSettings.Password = null; + } + collection.Add (context.ConnectionSettings); + } + + using (FileStream fs = new FileStream (configFile, FileMode.Create)) { + XmlSerializer serializer = new XmlSerializer (typeof (DatabaseConnectionSettingsCollection)); + serializer.Serialize (fs, collection); + } + + foreach (KeyValuePair<DatabaseConnectionSettings, string> pair in tmp) + pair.Key.Password = pair.Value; + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/AbstractPooledDbConnection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/AbstractPooledDbConnection.cs new file mode 100644 index 0000000000..6704cca22a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/AbstractPooledDbConnection.cs @@ -0,0 +1,330 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data; +using System.Threading;
+using System.Collections.Generic; +using MonoDevelop.Core;
+
+namespace MonoDevelop.Database.Sql
+{
+ public abstract class AbstractPooledDbConnection : IPooledDbConnection
+ { + protected IConnectionPool connectionPool; + protected IDbConnection connection; + + protected bool disposed = false; + + protected AbstractPooledDbConnection (IConnectionPool connectionPool, IDbConnection connection) + { + this.connectionPool = connectionPool; + this.connection = connection; + } +
+ public virtual IConnectionPool ConnectionPool { + get { return connectionPool; } + } + + public virtual IDbConnection DbConnection { + get { return connection; } + } + + public virtual bool IsOpen { + get { return connection.State == ConnectionState.Open; } + } + + public virtual void Release () + { + connectionPool.Release (this); + } + + public virtual void Destroy () + { + connection.Close (); + connection.Dispose (); + connection = null; + } + + public void Dispose () + { + Dispose (true); + GC.SuppressFinalize (this); + } + + protected virtual void Dispose (bool disposing) + { + if (!this.disposed) { + if (disposing) + Destroy (); + disposed = true; + } + } + + public virtual IDbCommand CreateCommand (IStatement statement) + { + if (statement == null) + throw new ArgumentNullException ("statement"); + + string sql = connectionPool.DbFactory.Dialect.GetSql (statement); + LoggingService.LogDebug ("Statement = {0}", sql); + + IDbCommand command = connection.CreateCommand (); + command.CommandType = CommandType.Text; + command.CommandText = sql; + return command; + } + + public virtual IDbCommand CreateCommand (string sql) + { + if (sql == null) + throw new ArgumentNullException ("sql"); + + IDbCommand command = connection.CreateCommand (); + command.CommandType = CommandType.Text; + command.CommandText = sql; + return command; + } + + public virtual IDbCommand CreateStoredProcedure (string procedure) + { + if (procedure == null) + throw new ArgumentNullException ("procedure"); + + IDbCommand command = connection.CreateCommand (); + command.CommandType = CommandType.StoredProcedure; + command.CommandText = procedure; + return command; + } + + public virtual int ExecuteNonQuery (string sql) + { + if (String.IsNullOrEmpty (sql)) + throw new ArgumentNullException ("sql"); + + int result = -1; + using (IDbCommand command = CreateCommand (sql)) + result = ExecuteNonQuery (command); + return result; + } + + public virtual object ExecuteScalar (string sql) + { + if (String.IsNullOrEmpty (sql)) + throw new ArgumentNullException ("sql"); + + object result = null; + using (IDbCommand command = CreateCommand (sql)) + result = ExecuteScalar (command); + return result; + } + + public virtual IDataReader ExecuteReader (string sql) + { + if (String.IsNullOrEmpty (sql)) + throw new ArgumentNullException ("sql"); + + IDataReader result = null; + using (IDbCommand command = CreateCommand (sql)) + result = ExecuteReader (command); + return result; + } + + public virtual DataSet ExecuteSet (string sql) + { + if (String.IsNullOrEmpty (sql)) + throw new ArgumentNullException ("sql"); + + DataSet result = null; + using (IDbCommand command = CreateCommand (sql)) + result = ExecuteSet (command); + return result; + } + + public virtual DataTable ExecuteTable (string sql) + { + if (String.IsNullOrEmpty (sql)) + throw new ArgumentNullException ("sql"); + + DataTable result = null; + using (IDbCommand command = CreateCommand (sql)) + result = ExecuteTable (command); + return result; + } + + public virtual int ExecuteNonQuery (IDbCommand command) + { + if (command == null) + throw new ArgumentNullException ("command"); + + try { + return command.ExecuteNonQuery (); + } catch (Exception e) { + QueryService.RaiseException (e); + return -1; + } + } + + public virtual object ExecuteScalar (IDbCommand command) + { + if (command == null) + throw new ArgumentNullException ("command"); + + try { + return command.ExecuteScalar (); + } catch (Exception e) { + QueryService.RaiseException (e); + return null; + } + } + + public virtual IDataReader ExecuteReader (IDbCommand command) + { + if (command == null) + throw new ArgumentNullException ("command"); + + try { + return command.ExecuteReader (); + } catch (Exception e) { + QueryService.RaiseException (e); + return null; + } + } + + public abstract DataSet ExecuteSet (IDbCommand command); + public abstract DataTable ExecuteTable (IDbCommand command); + + public virtual void ExecuteNonQueryAsync (IDbCommand command, ExecuteCallback<int> callback, object state) + { + if (command == null) + throw new ArgumentNullException ("command"); + if (callback == null) + throw new ArgumentNullException ("callback"); + + AsyncExecuteState<int> internalState = new AsyncExecuteState<int> (command, callback, state); + ThreadPool.QueueUserWorkItem (new WaitCallback (ExecuteNonQueryThreaded), internalState); + } + + public virtual void ExecuteScalarAsync (IDbCommand command, ExecuteCallback<object> callback, object state) + { + if (command == null) + throw new ArgumentNullException ("command"); + if (callback == null) + throw new ArgumentNullException ("callback"); + + AsyncExecuteState<object> internalState = new AsyncExecuteState<object> (command, callback, state); + ThreadPool.QueueUserWorkItem (new WaitCallback (ExecuteScalarThreaded), internalState); + } + + public virtual void ExecuteReaderAsync (IDbCommand command, ExecuteCallback<IDataReader> callback, object state) + { + if (command == null) + throw new ArgumentNullException ("command"); + if (callback == null) + throw new ArgumentNullException ("callback"); + + AsyncExecuteState<IDataReader> internalState = new AsyncExecuteState<IDataReader> (command, callback, state); + ThreadPool.QueueUserWorkItem (new WaitCallback (ExecuteReaderThreaded), internalState); + } + + public virtual void ExecuteSetAsync (IDbCommand command, ExecuteCallback<DataSet> callback, object state) + { + if (command == null) + throw new ArgumentNullException ("command"); + if (callback == null) + throw new ArgumentNullException ("callback"); + + AsyncExecuteState<DataSet> internalState = new AsyncExecuteState<DataSet> (command, callback, state); + ThreadPool.QueueUserWorkItem (new WaitCallback (ExecuteSetThreaded), internalState); + } + + public virtual void ExecuteTableAsync (IDbCommand command, ExecuteCallback<DataTable> callback, object state) + { + if (command == null) + throw new ArgumentNullException ("command"); + if (callback == null) + throw new ArgumentNullException ("callback"); + + AsyncExecuteState<DataTable> internalState = new AsyncExecuteState<DataTable> (command, callback, state); + ThreadPool.QueueUserWorkItem (new WaitCallback (ExecuteTableThreaded), internalState); + } + + public abstract DataTable GetSchema (string collectionName, params string[] restrictionValues); + + private void ExecuteNonQueryThreaded (object state) + { + AsyncExecuteState<int> internalState = state as AsyncExecuteState<int>; + + int result = ExecuteNonQuery (internalState.Command); + internalState.Callback (this, result, internalState.State); + } + + private void ExecuteScalarThreaded (object state) + { + AsyncExecuteState<object> internalState = state as AsyncExecuteState<object>; + + object result = ExecuteScalar (internalState.Command); + internalState.Callback (this, result, internalState.State); + } + + private void ExecuteReaderThreaded (object state) + { + AsyncExecuteState<IDataReader> internalState = state as AsyncExecuteState<IDataReader>; + + IDataReader result = ExecuteReader (internalState.Command); + internalState.Callback (this, result, internalState.State); + } + + private void ExecuteSetThreaded (object state) + { + AsyncExecuteState<DataSet> internalState = state as AsyncExecuteState<DataSet>; + + DataSet result = ExecuteSet (internalState.Command); + internalState.Callback (this, result, internalState.State); + } + + private void ExecuteTableThreaded (object state) + { + AsyncExecuteState<DataTable> internalState = state as AsyncExecuteState<DataTable>; + + DataTable result = ExecuteTable (internalState.Command); + internalState.Callback (this, result, internalState.State); + }
+ } + + internal class AsyncExecuteState<T> + { + public AsyncExecuteState (IDbCommand command, ExecuteCallback<T> callback, object state) + { + Command = command; + Callback = callback; + State = state; + } + + public IDbCommand Command; + public ExecuteCallback<T> Callback; + public object State; + }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/DefaultConnectionPool.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/DefaultConnectionPool.cs new file mode 100644 index 0000000000..b41e5d8a90 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/DefaultConnectionPool.cs @@ -0,0 +1,258 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class DefaultConnectionPool : IConnectionPool
+ { + protected int minSize = 1; + protected int maxSize = 20; + protected int growSize = 3; + protected int shrinkSize = 5; + + protected bool hasErrors; + protected string error; + + protected IDbFactory factory; + protected DatabaseConnectionContext context; + protected IConnectionProvider connectionProvider; + + protected bool isInitialized; + + protected List<IPooledDbConnection> connections; + protected Queue<IPooledDbConnection> freeConnections; + + protected object sync = new object (); + + public DefaultConnectionPool (IDbFactory factory, IConnectionProvider connectionProvider, DatabaseConnectionContext context) + { + if (factory == null) + throw new ArgumentNullException ("factory"); + if (connectionProvider == null) + throw new ArgumentNullException ("connectionProvider"); + if (context == null) + throw new ArgumentNullException ("context"); + + this.factory = factory; + this.connectionProvider = connectionProvider; + this.context = context; + + connections = new List<IPooledDbConnection> (); + freeConnections = new Queue<IPooledDbConnection> (); + } + + public virtual IDbFactory DbFactory { + get { return factory; } + } + + public virtual DatabaseConnectionContext ConnectionContext { + get { return context; } + } + + public virtual IConnectionProvider ConnectionProvider { + get { return connectionProvider; } + } + + public virtual bool IsInitialized { + get { return isInitialized; } + } + + public virtual bool HasErrors { + get { return hasErrors; } + } + + public virtual string Error { + get { return error; } + } +
+ public virtual int MinSize { + get { return minSize; } + set { + if (value < 1 || value > maxSize) + throw new IndexOutOfRangeException ("MinSize"); + minSize = value; + } + } + + public virtual int MaxSize { + get { return maxSize; } + set { + if (value < minSize) + throw new IndexOutOfRangeException ("MaxSize"); + maxSize = value; + } + } + + public virtual int GrowSize { + get { return growSize; } + set { + if (value < 1 || value > 10) + throw new IndexOutOfRangeException ("GrowSize"); + growSize = value; + } + } + + public virtual int ShrinkSize { + get { return shrinkSize; } + set { + if (value < 1 || value > 10) + throw new IndexOutOfRangeException ("GrowSize"); + shrinkSize = value; + } + } + + public virtual int ConnectionCount { + get { + lock (sync) + return connections.Count + freeConnections.Count; + } + } + + public virtual int FreeConnectionCount { + get { + lock (sync) + return freeConnections.Count; + } + } + + public virtual bool HasFreeConnection { + get { + lock (sync) + return freeConnections.Count > 0; + } + } + + public virtual IPooledDbConnection Request () + { + IPooledDbConnection conn = null; + if (HasFreeConnection) { + lock (sync) { + conn = freeConnections.Dequeue (); + connections.Add (conn); + } + } else { + if (Grow ()) + conn = Request (); + else + conn = null; + } + return conn; + } + + public virtual void Release (IPooledDbConnection connection) + { + if (connection == null) + return; + + lock (sync) { + if (freeConnections.Contains (connection)) + return; + + if (connectionProvider.CheckConnection (connection, context.ConnectionSettings)) + freeConnections.Enqueue (connection); + connections.Remove (connection); + } + Shrink (); + } + + public virtual bool Initialize () + { + if (isInitialized) + return true; + + isInitialized = CreateNewConnections (minSize); + if (!isInitialized) + Cleanup (); + + return isInitialized; + } + + protected virtual bool CreateNewConnections (int count) + { + for (int i=0; i<count; i++) { + if (!CreateNewConnection ()) + return false; + } + return true; + } + + protected virtual bool CreateNewConnection () + { + IPooledDbConnection conn = connectionProvider.CreateConnection (this, context.ConnectionSettings, out error); + if (conn == null || !conn.IsOpen) { + hasErrors = true; + return false; + } + + hasErrors = false; + lock (sync) + freeConnections.Enqueue (conn); + + return true; + } + + public virtual void Close () + { + Cleanup (); + isInitialized = false; + hasErrors = false; + error = null; + } + + protected virtual void Cleanup () + { + lock (sync) { + foreach (IPooledDbConnection conn in connections) + conn.Dispose (); + foreach (IPooledDbConnection conn in freeConnections) + conn.Dispose (); + } + } + + protected virtual bool Grow () + { + return CreateNewConnections (growSize); + } + + protected virtual void Shrink () + { + if (FreeConnectionCount < shrinkSize) + return; + + for (int i=0; i<shrinkSize; i++) { + if (HasFreeConnection) { + lock (sync) { + IPooledDbConnection conn = freeConnections.Dequeue (); + conn.Dispose (); + } + } + } + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/FakeConnectionPool.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/FakeConnectionPool.cs new file mode 100644 index 0000000000..9e8480b82c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/FakeConnectionPool.cs @@ -0,0 +1,158 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class FakeConnectionPool : IConnectionPool
+ { + protected IDbFactory factory; + protected DatabaseConnectionContext context; + protected IConnectionProvider connectionProvider; + + protected IPooledDbConnection connection; + protected bool inUse = false; + + protected bool hasErrors; + protected string error; + + protected bool isInitialized; + + public FakeConnectionPool (IDbFactory factory, IConnectionProvider connectionProvider, DatabaseConnectionContext context) + { + if (factory == null) + throw new ArgumentNullException ("factory"); + if (connectionProvider == null) + throw new ArgumentNullException ("connectionProvider"); + if (context == null) + throw new ArgumentNullException ("context"); + + this.factory = factory; + this.connectionProvider = connectionProvider; + this.context = context; + } + + public virtual IDbFactory DbFactory { + get { return factory; } + } + + public virtual DatabaseConnectionContext ConnectionContext { + get { return context; } + } + + public virtual IConnectionProvider ConnectionProvider { + get { return connectionProvider; } + } + + public virtual bool IsInitialized { + get { return isInitialized; } + } + + public virtual bool HasErrors { + get { return hasErrors; } + } + + public virtual string Error { + get { return error; } + } +
+ public virtual int MinSize { + get { return 1; } + set { throw new NotImplementedException (); } + } + + public virtual int MaxSize { + get { return 1; } + set { throw new NotImplementedException (); } + } + + public virtual int GrowSize { + get { throw new NotImplementedException (); } + set { throw new NotImplementedException (); } + } + + public virtual int ShrinkSize { + get { throw new NotImplementedException (); } + set { throw new NotImplementedException (); } + } + + public virtual int ConnectionCount { + get { return 1; } + } + + public virtual int FreeConnectionCount { + get { return (connection == null || (connection.IsOpen && !inUse)) ? 1 : 0; } + } + + public virtual bool HasFreeConnection { + get { return FreeConnectionCount == 1; } + } + + public virtual IPooledDbConnection Request () + { + Initialize (); //this does nothing when already initialized, so it's safe to call every time + + if (HasFreeConnection) { + inUse = true; + return connection; + } else { + throw new InvalidOperationException ("No connection available."); + } + } + + public virtual void Release (IPooledDbConnection connection) + { + if (this.connection == connection && connection != null) + inUse = false; + } + + public virtual bool Initialize () + { + if (isInitialized) + return true; + + connection = connectionProvider.CreateConnection (this, context.ConnectionSettings, out error); + if (connection == null) { + hasErrors = true; + return false; + } + + hasErrors = false; + isInitialized = true; + return true; + } + + public virtual void Close () + { + if (connection != null) + connection.Dispose (); + + isInitialized = false; + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/IConnectionPool.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/IConnectionPool.cs new file mode 100644 index 0000000000..e14591c3c0 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/IConnectionPool.cs @@ -0,0 +1,59 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public interface IConnectionPool
+ { + IDbFactory DbFactory { get; } + DatabaseConnectionContext ConnectionContext { get; } + + bool IsInitialized { get; } + bool HasErrors { get; } + + string Error { get; } +
+ int MinSize { get; set; } + int MaxSize { get; set; } + + int GrowSize { get; set; } + int ShrinkSize { get; set; } + + int ConnectionCount { get; } + int FreeConnectionCount { get; } + + bool HasFreeConnection { get; } + + IPooledDbConnection Request (); + void Release (IPooledDbConnection connection); + + bool Initialize (); + void Close ();
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/IPooledDbConnection.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/IPooledDbConnection.cs new file mode 100644 index 0000000000..94cce1d123 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/IPooledDbConnection.cs @@ -0,0 +1,71 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{ + public delegate void ExecuteCallback<T> (IPooledDbConnection connection, T result, object state); +
+ public interface IPooledDbConnection : IDisposable
+ {
+ IConnectionPool ConnectionPool { get; } + + IDbConnection DbConnection { get; } + + bool IsOpen { get; } + + void Release (); + + void Destroy (); + + IDbCommand CreateCommand (IStatement statement); + IDbCommand CreateCommand (string sql); + + IDbCommand CreateStoredProcedure (string sql); + + int ExecuteNonQuery (string sql); + object ExecuteScalar (string sql); + IDataReader ExecuteReader (string sql); + DataSet ExecuteSet (string sql); + DataTable ExecuteTable (string sql); + + int ExecuteNonQuery (IDbCommand command); + object ExecuteScalar (IDbCommand command); + IDataReader ExecuteReader (IDbCommand command); + DataSet ExecuteSet (IDbCommand command); + DataTable ExecuteTable (IDbCommand command); + + void ExecuteNonQueryAsync (IDbCommand command, ExecuteCallback<int> callback, object state); + void ExecuteScalarAsync (IDbCommand command, ExecuteCallback<object> callback, object state); + void ExecuteReaderAsync (IDbCommand command, ExecuteCallback<IDataReader> callback, object state); + void ExecuteSetAsync (IDbCommand command, ExecuteCallback<DataSet> callback, object state); + void ExecuteTableAsync (IDbCommand command, ExecuteCallback<DataTable> callback, object state); + + DataTable GetSchema (string collectionName, params string[] restrictionValues);
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/PooledCommand.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/PooledCommand.cs new file mode 100644 index 0000000000..0d508b74b2 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/PooledCommand.cs @@ -0,0 +1,123 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public sealed class PooledCommand : IDbCommand
+ { + private IPooledDbConnection connection; + private IDbCommand command; + + public PooledCommand (IPooledDbConnection connection, IDbCommand command) + { + if (connection == null) + throw new ArgumentNullException ("connection"); + if (command == null) + throw new ArgumentNullException ("command"); + + this.connection = connection; + this.command = command; + } + + public string CommandText { + get { return command.CommandText; } + set { command.CommandText = value; } + } + + public int CommandTimeout { + get { return command.CommandTimeout; } + set { command.CommandTimeout = value; } + } + + public CommandType CommandType { + get { return command.CommandType; } + set { command.CommandType = value; } + } + + public IDbConnection Connection { + get { return command.Connection; } + set { command.Connection = value; } + } + + public IDataParameterCollection Parameters { + get { return command.Parameters; } + } + + public IDbTransaction Transaction { + get { return command.Transaction; } + set { command.Transaction = value; } + } + + public UpdateRowSource UpdatedRowSource { + get { return command.UpdatedRowSource; } + set { command.UpdatedRowSource = value; } + } + + public void Dispose () + { + command.Dispose (); + connection.Release (); + } + + public void Cancel () + { + command.Cancel (); + } + + public IDbDataParameter CreateParameter () + { + return command.CreateParameter (); + } + + public int ExecuteNonQuery () + { + return command.ExecuteNonQuery (); + } + + public IDataReader ExecuteReader () + { + return command.ExecuteReader (); + } + + public IDataReader ExecuteReader (CommandBehavior behavior) + { + return command.ExecuteReader (behavior); + } + + public object ExecuteScalar () + { + return command.ExecuteScalar (); + } + + public void Prepare () + { + command.Prepare (); + }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/PooledDataReader.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/PooledDataReader.cs new file mode 100644 index 0000000000..93adcc6200 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/ConnectionPool/PooledDataReader.cs @@ -0,0 +1,225 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public sealed class PooledDataReader : IDataReader
+ {
+ private IPooledDbConnection connection;
+ private IDataReader reader;
+
+ public PooledDataReader (IPooledDbConnection connection, IDataReader reader)
+ { + if (connection == null) + throw new ArgumentNullException ("connection"); + if (reader == null) + throw new ArgumentNullException ("reader"); +
+ this.connection = connection;
+ this.reader = reader;
+ }
+
+ public IPooledDbConnection Connection
+ {
+ get { return connection; }
+ }
+
+ public IDataReader DataReader
+ {
+ get { return reader; }
+ }
+
+ public void Dispose ()
+ {
+ reader.Dispose (); + connection.Release ();
+ }
+
+ public void Close ()
+ {
+ connection.Release ();
+ reader.Close ();
+ }
+
+ public int Depth
+ {
+ get { return reader.Depth; }
+ }
+
+ public DataTable GetSchemaTable ()
+ {
+ return reader.GetSchemaTable ();
+ }
+
+ public bool IsClosed
+ {
+ get { return reader.IsClosed; }
+ }
+
+ public bool NextResult ()
+ {
+ return reader.NextResult ();
+ }
+
+ public bool Read ()
+ {
+ return reader.Read ();
+ }
+
+ public int RecordsAffected
+ {
+ get { return reader.RecordsAffected; }
+ }
+
+ public int FieldCount
+ {
+ get { return reader.FieldCount; }
+ }
+
+ public bool GetBoolean (int i)
+ {
+ return reader.GetBoolean (i);
+ }
+
+ public byte GetByte (int i)
+ {
+ return reader.GetByte (i);
+ }
+
+ public long GetBytes (int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
+ {
+ return reader.GetBytes (i, fieldOffset, buffer, bufferoffset, length);
+ }
+
+ public char GetChar (int i)
+ {
+ return reader.GetChar (i);
+ }
+
+ public long GetChars (int i, long fieldoffset, char[] buffer, int bufferoffset, int length)
+ {
+ return reader.GetChars (i, fieldoffset, buffer, bufferoffset, length);
+ }
+
+ public IDataReader GetData (int i)
+ {
+ return reader.GetData (i);
+ }
+
+ public string GetDataTypeName (int i)
+ {
+ return reader.GetDataTypeName (i);
+ }
+
+ public DateTime GetDateTime (int i)
+ {
+ return reader.GetDateTime (i);
+ }
+
+ public decimal GetDecimal (int i)
+ {
+ return reader.GetDecimal (i);
+ }
+
+ public double GetDouble (int i)
+ {
+ return reader.GetDouble (i);
+ }
+
+ public Type GetFieldType (int i)
+ {
+ return reader.GetFieldType (i);
+ }
+
+ public float GetFloat (int i)
+ {
+ return reader.GetFloat (i);
+ }
+
+ public Guid GetGuid (int i)
+ {
+ return reader.GetGuid (i);
+ }
+
+ public short GetInt16 (int i)
+ {
+ return reader.GetInt16 (i);
+ }
+
+ public int GetInt32 (int i)
+ {
+ return reader.GetInt32 (i);
+ }
+
+ public long GetInt64 (int i)
+ {
+ return reader.GetInt64 (i);
+ }
+
+ public string GetName (int i)
+ {
+ return reader.GetName (i);
+ }
+
+ public int GetOrdinal (string name)
+ {
+ return reader.GetOrdinal (name);
+ }
+
+ public string GetString (int i)
+ {
+ return reader.GetString (i);
+ }
+
+ public object GetValue (int i)
+ {
+ return reader.GetValue (i);
+ }
+
+ public int GetValues (object[] values)
+ {
+ return reader.GetValues (values);
+ }
+
+ public bool IsDBNull (int i)
+ {
+ return reader.IsDBNull (i);
+ }
+
+ public object this[string name]
+ {
+ get { return reader[name]; }
+ }
+
+ public object this[int i]
+ {
+ get { return reader[i]; }
+ }
+ }
+}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/DbFactoryService.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/DbFactoryService.cs new file mode 100644 index 0000000000..87fbc6ea3c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/DbFactoryService.cs @@ -0,0 +1,101 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; +using Mono.Addins; +using MonoDevelop.Core; + +namespace MonoDevelop.Database.Sql +{ + public static class DbFactoryService + { + private static Dictionary<string, IDbFactory> factories; + + static DbFactoryService () + { + factories = new Dictionary<string, IDbFactory> (); + foreach (DbFactoryCodon codon in AddinManager.GetExtensionNodes ("/MonoDevelop/Database/Sql")) { + IDbFactory fac = codon.DbFactory; + if (fac != null) { + factories.Add (fac.Identifier, fac); + LoggingService.LogDebug ("DB FACTORY: " + fac.Identifier); + } + } + } + + public static IEnumerable<IDbFactory> DbFactories { + get { return factories.Values; } + } + + public static int DbFactoryCount { + get { return factories.Count; } + } + + public static IDbFactory GetDbFactory (string id) + { + if (id == null) + throw new ArgumentNullException ("id"); + + IDbFactory fac = null; + if (factories.TryGetValue (id, out fac)) + return fac; + return null; + } + + public static IDbFactory GetDbFactory (DatabaseConnectionSettings settings) + { + if (settings == null) + throw new ArgumentNullException ("settings"); + + return GetDbFactory (settings.ProviderIdentifier); + } + + public static IConnectionPool CreateConnectionPool (DatabaseConnectionContext context) + { + if (context == null) + throw new ArgumentNullException ("context"); + + IDbFactory fac = GetDbFactory (context.ConnectionSettings); + if (fac != null) + return fac.CreateConnectionPool (context); + return null; + } + + public static ISchemaProvider CreateSchemaProvider (DatabaseConnectionContext context, IConnectionPool pool) + { + if (context == null) + throw new ArgumentNullException ("context"); + if (pool == null) + throw new ArgumentNullException ("pool"); + + IDbFactory fac = GetDbFactory (context.ConnectionSettings); + if (fac != null) + return fac.CreateSchemaProvider (pool); + return null; + } + } +} diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/AbstractSqlDialect.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/AbstractSqlDialect.cs new file mode 100644 index 0000000000..2d5d5e3185 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/AbstractSqlDialect.cs @@ -0,0 +1,488 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Text; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public abstract class AbstractSqlDialect : ISqlDialect + { + public abstract string QuoteIdentifier (string identifier); + + public abstract string MarkAsParameter (string identifier); + + public virtual string GetSql (IStatement statement) + { + if (statement == null) + throw new ArgumentNullException ("statement"); + + Type type = statement.GetType (); + if (type == typeof (SelectStatement)) + return GetStatementSql (statement as SelectStatement); + else if (type == typeof (InsertStatement)) + return GetStatementSql (statement as InsertStatement); + else if (type == typeof (UpdateStatement)) + return GetStatementSql (statement as UpdateStatement); + else if (type == typeof (DeleteStatement)) + return GetStatementSql (statement as DeleteStatement); + else if (type == typeof (DropStatement)) + return GetStatementSql (statement as DropStatement); + else if (type == typeof (TruncateStatement)) + return GetStatementSql (statement as TruncateStatement); + else + throw new NotImplementedException (type.FullName); + } + + public virtual string GetSql (IClause clause) + { + if (clause == null) + throw new ArgumentNullException ("clause"); + + Type type = clause.GetType (); + if (type == typeof (FromSelectClause)) + return GetClauseSql (clause as FromSelectClause); + else if (type == typeof (FromTableClause)) + return GetClauseSql (clause as FromTableClause); + else if (type == typeof (WhereClause)) + return GetClauseSql (clause as WhereClause); + else if (type == typeof (HavingClause)) + return GetClauseSql (clause as HavingClause); + else if (type == typeof (JoinClause)) + return GetClauseSql (clause as JoinClause); + else if (type == typeof (OrderByClause)) + return GetClauseSql (clause as OrderByClause); + else if (type == typeof (GroupByClause)) + return GetClauseSql (clause as GroupByClause); + else if (type == typeof (UnionClause)) + return GetClauseSql (clause as UnionClause); + else + throw new NotImplementedException (type.FullName); + } + + public virtual string GetSql (IExpression expr) + { + if (expr == null) + throw new ArgumentNullException ("expr"); + + Type type = expr.GetType (); + if (type == typeof (AliasedIdentifierExpression)) + return GetExpressionSql (expr as AliasedIdentifierExpression); + else if (type == typeof (IdentifierExpression)) + return GetExpressionSql (expr as IdentifierExpression); + else if (type == typeof (BooleanExpression)) + return GetExpressionSql (expr as BooleanExpression); + else if (type == typeof (OperatorExpression)) + return GetExpressionSql (expr as OperatorExpression); + else if (type == typeof (ParameterExpression)) + return GetExpressionSql (expr as ParameterExpression); + else + throw new NotImplementedException (type.FullName); + } + + public virtual string GetSql (ILiteral literal) + { + if (literal == null) + throw new ArgumentNullException ("literal"); + + Type type = literal.GetType (); + if (type == typeof (StringLiteral)) + return GetLiteralSql (literal as StringLiteral); + else if (type == typeof (NumericLiteral)) + return GetLiteralSql (literal as NumericLiteral); + else if (type == typeof (BooleanLiteral)) + return GetLiteralSql (literal as BooleanLiteral); + else if (type == typeof (NullLiteral)) + return GetLiteralSql (literal as NullLiteral); + else if (type == typeof (TrueLiteral)) + return GetLiteralSql (literal as TrueLiteral); + else if (type == typeof (FalseLiteral)) + return GetLiteralSql (literal as FalseLiteral); + else if (type == typeof (HexLiteral)) + return GetLiteralSql (literal as HexLiteral); + else if (type == typeof (BitLiteral)) + return GetLiteralSql (literal as BitLiteral); + else + throw new NotImplementedException (type.FullName); + } + + protected virtual string GetStatementSql (SelectStatement statement) + { + StringBuilder sb = new StringBuilder (); + + sb.Append ("SELECT "); + bool first = true; + foreach (IdentifierExpression expr in statement.Columns) { + if (first) + first = false; + else + sb.Append (','); + + sb.Append (GetSql (expr)); + } + + sb.Append (' '); + sb.Append (Environment.NewLine); + sb.Append (GetSql (statement.From)); + + if (statement.Where != null) { + sb.Append (GetSql (statement.Where)); + sb.Append (' '); + sb.Append (Environment.NewLine); + } + + if (statement.OrderBy != null) { + sb.Append (GetSql (statement.OrderBy)); + sb.Append (' '); + sb.Append (Environment.NewLine); + } + + if (statement.GroupBy != null) { + sb.Append (GetSql (statement.GroupBy)); + sb.Append (' '); + sb.Append (Environment.NewLine); + } + + if (statement.Having != null) { + sb.Append (GetSql (statement.Having)); + sb.Append (' '); + sb.Append (Environment.NewLine); + } + + if (statement.Union != null) { + sb.Append (GetSql (statement.Union)); + sb.Append (' '); + sb.Append (Environment.NewLine); + } + + if (statement.Join != null) { + sb.Append (GetSql (statement.Join)); + sb.Append (' '); + sb.Append (Environment.NewLine); + } + + sb.Append (';'); + + return sb.ToString (); + } + + protected virtual string GetStatementSql (InsertStatement statement) + { + StringBuilder sb = new StringBuilder (); + + sb.Append ("INSERT INTO "); + sb.Append (GetSql (statement.Identifier)); + + if (statement.Columns.Count > 0) { + sb.Append (Environment.NewLine); + sb.Append (" ("); + int columnCount = statement.Columns.Count; + for (int i=0; i<columnCount; i++) { + sb.Append (GetSql (statement.Columns[i])); + sb.Append (i == (columnCount - 1) ? ", " : ""); + } + sb.Append (")"); + } + + sb.Append (Environment.NewLine); + sb.Append (" VALUES "); + + int rowCount = statement.Values.Count; + for (int j=0; j<rowCount; j++) { + sb.Append ("("); + List<IExpression> expr = statement.Values[j]; + + int columnCount = expr.Count; + for (int i=0; i<columnCount; i++) { + sb.Append (GetSql (expr[i])); + sb.Append (i == (columnCount - 1) ? ", " : ""); + } + + sb.Append (")"); + sb.Append (j == (rowCount - 1) ? "," + Environment.NewLine : ""); + } + + sb.Append (';'); + return sb.ToString (); + } + + protected virtual string GetStatementSql (UpdateStatement statement) + { + StringBuilder sb = new StringBuilder (); + + sb.Append ("UPDATE "); + sb.Append (GetSql (statement.Identifier)); + sb.Append (' '); + sb.Append (Environment.NewLine); + + sb.Append ("SET "); + + int columnCount = statement.Columns.Count; + for (int i=0; i<columnCount; i++) { + OperatorExpression expr = new OperatorExpression (statement.Columns[i], Operator.Equals, statement.Values[i]); + sb.Append (expr); + sb.Append (i == (columnCount - 1) ? ", " : ""); + } + + if (statement.Where != null) { + sb.Append (GetSql (statement.Where)); + sb.Append (' '); + sb.Append (Environment.NewLine); + } + + sb.Append (';'); + return sb.ToString (); + } + + protected virtual string GetStatementSql (DeleteStatement statement) + { + StringBuilder sb = new StringBuilder (); + + sb.Append ("DELETE "); + sb.Append (GetSql (statement.From)); + + if (statement.Where != null) { + sb.Append (GetSql (statement.Where)); + sb.Append (' '); + sb.Append (Environment.NewLine); + } + + sb.Append (';'); + + return sb.ToString (); + } + + protected virtual string GetStatementSql (DropStatement statement) + { + StringBuilder sb = new StringBuilder (); + + sb.Append ("DROP "); + switch (statement.DropType) { + case DropStatementType.Database: + sb.Append ("DATABASE "); + break; + case DropStatementType.Table: + sb.Append ("TABLE "); + break; + case DropStatementType.Index: + sb.Append ("INDEX "); + break; + case DropStatementType.Procedure: + sb.Append ("PROCEDURE "); + break; + case DropStatementType.View: + sb.Append ("VIEW "); + break; + } + + sb.Append (GetSql (statement.Identifier)); + sb.Append (';'); + + return sb.ToString (); + } + + protected virtual string GetStatementSql (TruncateStatement statement) + { + StringBuilder sb = new StringBuilder (); + + sb.Append ("TRUNCATE "); + sb.Append (GetSql (statement.Identifier)); + sb.Append (';'); + + return sb.ToString (); + } + + protected virtual string GetClauseSql (FromSelectClause clause) + { + return String.Concat ("FROM ", GetStatementSql (clause.Source)); + } + + protected virtual string GetClauseSql (FromTableClause clause) + { + return String.Concat ("FROM ", GetExpressionSql (clause.Source)); + } + + protected virtual string GetClauseSql (WhereClause clause) + { + return String.Concat ("WHERE ", GetSql (clause.Condition)); + } + + protected virtual string GetClauseSql (OrderByClause clause) + { + throw new NotImplementedException (); + } + + protected virtual string GetClauseSql (GroupByClause clause) + { + throw new NotImplementedException (); + } + + protected virtual string GetClauseSql (UnionClause clause) + { + throw new NotImplementedException (); + } + + protected virtual string GetClauseSql (JoinClause clause) + { + throw new NotImplementedException (); + } + + protected virtual string GetClauseSql (HavingClause clause) + { + throw new NotImplementedException (); + } + + protected virtual string GetLiteralSql (StringLiteral literal) + { + return String.Concat ("'", literal.Value, "'"); + } + + protected virtual string GetLiteralSql (NumericLiteral literal) + { + return literal.Value; + } + + protected virtual string GetLiteralSql (NullLiteral literal) + { + return "NULL"; + } + + protected virtual string GetLiteralSql (TrueLiteral literal) + { + return "TRUE"; + } + + protected virtual string GetLiteralSql (FalseLiteral literal) + { + return "FALSE"; + } + + protected virtual string GetLiteralSql (HexLiteral literal) + { + // X'ABCD' + return String.Concat ("X'", literal.Value, "'"); + } + + protected virtual string GetLiteralSql (BitLiteral literal) + { + // B'01011010' + return String.Concat ("B'", literal.Value, "'"); + } + + protected virtual string GetLiteralSql (BooleanLiteral literal) + { + if (literal.Value) + return "TRUE"; + return "FALSE"; + } + + protected virtual string GetExpressionSql (AliasedIdentifierExpression expr) + { + return String.Concat (GetIdentifierName (expr.Name), " AS ", GetIdentifierName (expr.Alias)); + } + + protected virtual string GetExpressionSql (IdentifierExpression expr) + { + return GetIdentifierName (expr.Name); + } + + protected virtual string GetIdentifierName (string identifier) + { + return QuoteIdentifier (identifier); + } + + protected virtual string GetExpressionSql (BooleanExpression expr) + { + return String.Concat ("(", GetSql (expr.Left), " ", + GetOperatorSql (expr.Operator), " ", + GetSql (expr.Right), ")"); + } + + protected virtual string GetExpressionSql (OperatorExpression expr) + { + return String.Concat ("(", GetSql (expr.Left), " ", + GetOperatorSql (expr.Operator), " ", + GetSql (expr.Right), ")"); + } + + protected virtual string GetExpressionSql (ParameterExpression expr) + { + return MarkAsParameter (expr.Name); + } + + protected virtual string GetOperatorSql (Operator op) + { + switch (op) { + case Operator.Equals: + return "=";
+ case Operator.NotEqual: + return "!=";
+ case Operator.GreaterThanOrEqual: + return ">=";
+ case Operator.GreaterThan: + return ">";
+ case Operator.LessThanOrEqual: + return "<=";
+ case Operator.LessThan: + return "<";
+ case Operator.Plus: + return "+";
+ case Operator.Minus: + return "-";
+ case Operator.Divide: + return "/";
+ case Operator.Multiply: + return "*";
+ case Operator.Modus:
+ return "%";
+ case Operator.Is: + return "IS"; + case Operator.IsNot: + return "IS NOT"; + case Operator.In: + return "IN"; + case Operator.Like: + return "LIKE"; + default: + throw new NotImplementedException (); + } + } + + protected virtual string GetOperatorSql (BooleanOperator op) + { + bool not = ((op & BooleanOperator.Not) == BooleanOperator.Not); + bool and = ((op & BooleanOperator.And) == BooleanOperator.And); + bool or = ((op & BooleanOperator.Or) == BooleanOperator.Or); + + if (and) + if (not) return "AND NOT"; else return "AND"; + else if (or) + if (not) return "OR NOT"; else return "OR"; + else return "NOT"; + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/FromClause.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/FromClause.cs new file mode 100644 index 0000000000..cd99a3f9d8 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/FromClause.cs @@ -0,0 +1,36 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public abstract class FromClause : IClause + { + + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/FromSelectClause.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/FromSelectClause.cs new file mode 100644 index 0000000000..45a38cccd3 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/FromSelectClause.cs @@ -0,0 +1,50 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class FromSelectClause : FromClause + { + protected SelectStatement source; + + public FromSelectClause (SelectStatement source) + { + Source = source; + } + + public SelectStatement Source { + get { return source; } + set { + if (value == null) + throw new ArgumentNullException ("source"); + source = value; + } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/FromTableClause.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/FromTableClause.cs new file mode 100644 index 0000000000..f2bfcc8b48 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/FromTableClause.cs @@ -0,0 +1,50 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class FromTableClause : FromClause + { + protected IdentifierExpression source; + + public FromTableClause (IdentifierExpression source) + { + Source = source; + } + + public IdentifierExpression Source { + get { return source; } + set { + if (value == null) + throw new ArgumentNullException ("source"); + source = value; + } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/GroupByClause.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/GroupByClause.cs new file mode 100644 index 0000000000..4c38a2cbb4 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/GroupByClause.cs @@ -0,0 +1,36 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class GroupByClause : IClause + { + //TODO + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/HavingClause.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/HavingClause.cs new file mode 100644 index 0000000000..000f77e55d --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/HavingClause.cs @@ -0,0 +1,36 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class HavingClause : IClause + { + //TODO + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/IClause.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/IClause.cs new file mode 100644 index 0000000000..03788ce9b1 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/IClause.cs @@ -0,0 +1,35 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public interface IClause + { + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/JoinClause.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/JoinClause.cs new file mode 100644 index 0000000000..f7dacc4864 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/JoinClause.cs @@ -0,0 +1,36 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class JoinClause : IClause + { + //TODO + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/JoinClauseType.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/JoinClauseType.cs new file mode 100644 index 0000000000..8f19baff15 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/JoinClauseType.cs @@ -0,0 +1,40 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public enum JoinClauseType + {
+ Inner,
+ OuterLeft,
+ OuterRight,
+ OuterFull, + Cross + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/OrderByClause.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/OrderByClause.cs new file mode 100644 index 0000000000..ff1ad1ef48 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/OrderByClause.cs @@ -0,0 +1,36 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class OrderByClause : IClause + { + //TODO + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/UnionClause.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/UnionClause.cs new file mode 100644 index 0000000000..bfc1ad2357 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/UnionClause.cs @@ -0,0 +1,50 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class UnionClause : IClause + { + protected SelectStatement union; + + public UnionClause (SelectStatement union) + { + Union = union; + } + + public SelectStatement Union { + get { return union; } + set { + if (value == null) + throw new ArgumentNullException ("union"); + union = value; + } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/WhereClause.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/WhereClause.cs new file mode 100644 index 0000000000..7e24957e12 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Clauses/WhereClause.cs @@ -0,0 +1,50 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class WhereClause : IClause + { + protected IConditionalExpression condition; + + public WhereClause (IConditionalExpression condition) + { + Condition = condition; + } + + public IConditionalExpression Condition { + get { return condition; } + set { + if (value == null) + throw new ArgumentNullException ("condition"); + condition = value; + } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/AliasedIdentifierExpression.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/AliasedIdentifierExpression.cs new file mode 100644 index 0000000000..ccb0f2aca3 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/AliasedIdentifierExpression.cs @@ -0,0 +1,51 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class AliasedIdentifierExpression : IdentifierExpression + { + protected string alias; + + public AliasedIdentifierExpression (string name, string alias) + : base (name) + { + Alias = alias; + } + + public string Alias { + get { return alias; } + set { + if (value == null) + throw new ArgumentNullException ("alias"); + alias = value; + } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/BooleanExpression.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/BooleanExpression.cs new file mode 100644 index 0000000000..7cc9d4324d --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/BooleanExpression.cs @@ -0,0 +1,68 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class BooleanExpression : IConditionalExpression + { + protected IExpression left; + protected IExpression right; + protected BooleanOperator op; + + public BooleanExpression (IExpression left, BooleanOperator op, IExpression right) + { + Left = left; + Operator = op; + Right = right; + } + + public IExpression Left { + get { return left; } + set { + if (value == null) + throw new ArgumentNullException ("left"); + left = value; + } + } + + public IExpression Right { + get { return right; } + set { + if (value == null) + throw new ArgumentNullException ("right"); + right = value; + } + } + + public BooleanOperator Operator { + get { return op; } + set { op = value; } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/BooleanOperator.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/BooleanOperator.cs new file mode 100644 index 0000000000..c3c3a6e4dd --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/BooleanOperator.cs @@ -0,0 +1,39 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + [Flags] + public enum BooleanOperator + { + And, + Or, + Not + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/IConditionalExpression.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/IConditionalExpression.cs new file mode 100644 index 0000000000..7527474909 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/IConditionalExpression.cs @@ -0,0 +1,35 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public interface IConditionalExpression : IExpression + { + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/IExpression.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/IExpression.cs new file mode 100644 index 0000000000..c496af2929 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/IExpression.cs @@ -0,0 +1,35 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public interface IExpression + { + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/IdentifierExpression.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/IdentifierExpression.cs new file mode 100644 index 0000000000..5acbbfd300 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/IdentifierExpression.cs @@ -0,0 +1,55 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class IdentifierExpression : IExpression + { + protected string name; + + public IdentifierExpression () + : this ("*") + { + } + + public IdentifierExpression (string name) + { + Name = name; + } + + public string Name { + get { return name; } + set { + if (value == null) + throw new ArgumentNullException ("name"); + name = value; + } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/Operator.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/Operator.cs new file mode 100644 index 0000000000..2cefdff108 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/Operator.cs @@ -0,0 +1,53 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public enum Operator + { + Equals,
+ NotEqual,
+
+ GreaterThanOrEqual,
+ GreaterThan,
+ LessThanOrEqual,
+ LessThan,
+
+ Plus,
+ Minus,
+ Divide,
+ Multiply,
+ Modus,
+
+ Is, + IsNot, + In, + Like + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/OperatorExpression.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/OperatorExpression.cs new file mode 100644 index 0000000000..3dbc550704 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/OperatorExpression.cs @@ -0,0 +1,68 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class OperatorExpression : IConditionalExpression + { + protected IExpression left; + protected IExpression right; + protected Operator op; + + public OperatorExpression (IExpression left, Operator op, IExpression right) + { + Left = left; + Operator = op; + Right = right; + } + + public IExpression Left { + get { return left; } + set { + if (value == null) + throw new ArgumentNullException ("left"); + left = value; + } + } + + public IExpression Right { + get { return right; } + set { + if (value == null) + throw new ArgumentNullException ("right"); + right = value; + } + } + + public Operator Operator { + get { return op; } + set { op = value; } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/ParameterExpression.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/ParameterExpression.cs new file mode 100644 index 0000000000..4fbe452469 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Expressions/ParameterExpression.cs @@ -0,0 +1,39 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class ParameterExpression : IdentifierExpression + { + public ParameterExpression (string name) + : base (name) + { + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/ISqlDialect.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/ISqlDialect.cs new file mode 100644 index 0000000000..10ef738ac8 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/ISqlDialect.cs @@ -0,0 +1,47 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public interface ISqlDialect + { + //TODO: method for checking if the statement/clause/... is supported + string QuoteIdentifier (string identifier); + + string MarkAsParameter (string identifier); + + string GetSql (IStatement statement); + + string GetSql (IClause clause); + + string GetSql (IExpression expression); + + string GetSql (ILiteral literal); + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/BitLiteral.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/BitLiteral.cs new file mode 100644 index 0000000000..df2b0ad9e4 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/BitLiteral.cs @@ -0,0 +1,39 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class BitLiteral : StringLiteral + { + public BitLiteral (string value) + { + Value = value; + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/BooleanLiteral.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/BooleanLiteral.cs new file mode 100644 index 0000000000..6f13780f39 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/BooleanLiteral.cs @@ -0,0 +1,46 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class BooleanLiteral : ILiteral + { + protected bool val; + + public BooleanLiteral (bool value) + { + Value = value; + } + + public bool Value { + get { return val; } + set { val = value; } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/FalseLiteral.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/FalseLiteral.cs new file mode 100644 index 0000000000..a98adbe06a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/FalseLiteral.cs @@ -0,0 +1,35 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class FalseLiteral : ILiteral + { + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/HexLiteral.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/HexLiteral.cs new file mode 100644 index 0000000000..857999975e --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/HexLiteral.cs @@ -0,0 +1,94 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class HexLiteral : StringLiteral + { + public HexLiteral (string value) + { + if (value.Length % 2 != 0) + throw new ArgumentException ("Invalid hexadecimal value, the length must be a factor of 2."); + + Value = value; + } + + public HexLiteral (byte[] value) + { + Value = ToHexString (value); + } + + public HexLiteral (int value) + { + Value = ToHexString (BitConverter.GetBytes (value)); + } + + public HexLiteral (uint value) + { + Value = ToHexString (BitConverter.GetBytes (value)); + } + + public HexLiteral (long value) + { + Value = ToHexString (BitConverter.GetBytes (value)); + } + + public HexLiteral (ulong value) + { + Value = ToHexString (BitConverter.GetBytes (value)); + } + + public HexLiteral (float value) + { + Value = ToHexString (BitConverter.GetBytes (value)); + } + + public HexLiteral (double value) + { + Value = ToHexString (BitConverter.GetBytes (value)); + } + + // see: http://www.codeproject.com/csharp/hexencoding.asp?msg=1064904#xx1064904xx + internal static string ToHexString (byte[] bytes) + { + char[] hexDigits = { + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' + }; + + char[] chars = new char[bytes.Length * 2]; + for (int i = 0; i < bytes.Length; i++) { + int b = bytes[i]; + chars[i * 2] = hexDigits[b >> 4]; + chars[i * 2 + 1] = hexDigits[b & 0xF]; + } + return new string(chars); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/ILiteral.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/ILiteral.cs new file mode 100644 index 0000000000..46756d59e5 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/ILiteral.cs @@ -0,0 +1,35 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public interface ILiteral : IExpression + { + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/NullLiteral.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/NullLiteral.cs new file mode 100644 index 0000000000..d429d7e071 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/NullLiteral.cs @@ -0,0 +1,35 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class NullLiteral : ILiteral + { + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/NumericLiteral.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/NumericLiteral.cs new file mode 100644 index 0000000000..da78688c5a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/NumericLiteral.cs @@ -0,0 +1,69 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class NumericLiteral : StringLiteral + { + public NumericLiteral (int value) + { + Value = value.ToString (); + } + + public NumericLiteral (uint value) + { + Value = value.ToString (); + } + + public NumericLiteral (long value) + { + Value = value.ToString (); + } + + public NumericLiteral (ulong value) + { + Value = value.ToString (); + } + + public NumericLiteral (float value) + { + Value = value.ToString (); + } + + public NumericLiteral (double value) + { + Value = value.ToString (); + } + + public NumericLiteral (decimal value) + { + Value = value.ToString (); + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/StringLiteral.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/StringLiteral.cs new file mode 100644 index 0000000000..290ebcc561 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/StringLiteral.cs @@ -0,0 +1,54 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class StringLiteral : ILiteral + { + protected string val; + + protected StringLiteral () + { + } + + public StringLiteral (string value) + { + Value = value; + } + + public string Value { + get { return val; } + set { + if (value == null) + throw new ArgumentNullException ("value"); + val = value; + } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/TrueLiteral.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/TrueLiteral.cs new file mode 100644 index 0000000000..4d717ca079 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Literals/TrueLiteral.cs @@ -0,0 +1,35 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class TrueLiteral : ILiteral + { + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/DeleteStatement.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/DeleteStatement.cs new file mode 100644 index 0000000000..dc4a9d382c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/DeleteStatement.cs @@ -0,0 +1,56 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class DeleteStatement : IStatement + { + protected FromClause from; + protected WhereClause where; + + public DeleteStatement (FromClause from) + { + From = from; + }
+
+ public FromClause From { + get { return from; } + set { + if (value == null) + throw new ArgumentNullException ("from"); + this.from = value; + } + }
+
+ public WhereClause Where { + get { return where; } + set { where = value; } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/DropStatement.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/DropStatement.cs new file mode 100644 index 0000000000..4605316f47 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/DropStatement.cs @@ -0,0 +1,57 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class DropStatement : IStatement + { + protected IdentifierExpression identifier; + protected DropStatementType dropType; + + public DropStatement (IdentifierExpression identifier, DropStatementType dropType) + { + Identifier = identifier; + DropType = dropType; + }
+
+ public IdentifierExpression Identifier { + get { return identifier; } + set { + if (value == null) + throw new ArgumentNullException ("identifier"); + identifier = value; + } + }
+
+ public DropStatementType DropType { + get { return dropType; } + set { dropType = value; } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/DropStatementType.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/DropStatementType.cs new file mode 100644 index 0000000000..8bded84b0d --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/DropStatementType.cs @@ -0,0 +1,40 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public enum DropStatementType + { + Database, + Table, + Index, + View, + Procedure + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/IStatement.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/IStatement.cs new file mode 100644 index 0000000000..9408b5430f --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/IStatement.cs @@ -0,0 +1,35 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public interface IStatement + { + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/InsertStatement.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/InsertStatement.cs new file mode 100644 index 0000000000..7cc52c0e49 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/InsertStatement.cs @@ -0,0 +1,70 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class InsertStatement : IStatement + { + protected IdentifierExpression identifier; + protected List<IdentifierExpression> columns; + protected List<List<IExpression>> values; + + public InsertStatement (IdentifierExpression identifier, IEnumerable<IdentifierExpression> columns, IEnumerable<IEnumerable<IExpression>> values) + { + Identifier = identifier; + + this.columns = new List<IdentifierExpression> (); + this.values = new List<List<IExpression>> (); + + this.columns.AddRange (columns); + foreach (IEnumerable<IExpression> row in values) { + List<IExpression> expr = new List<IExpression> (); + expr.AddRange (row); + this.Values.Add (expr); + } + }
+
+ public IdentifierExpression Identifier { + get { return identifier; } + set { + if (value == null) + throw new ArgumentNullException ("identifier"); + identifier = value; + } + }
+
+ public List<IdentifierExpression> Columns { + get { return columns; } + } + + public List<List<IExpression>> Values { + get { return values; } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/SelectStatement.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/SelectStatement.cs new file mode 100644 index 0000000000..8a7d1c4c8a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/SelectStatement.cs @@ -0,0 +1,107 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class SelectStatement : IStatement + { + protected List<IdentifierExpression> columns; + protected FromClause from; + protected WhereClause where; + protected OrderByClause orderBy; + protected GroupByClause groupBy; + protected HavingClause having; + protected UnionClause union; + protected JoinClause join; + + public SelectStatement (FromClause from) + { + if (from == null) + throw new ArgumentNullException ("from"); + From = from; + this.columns = new List<IdentifierExpression> (); + this.columns.Add (new IdentifierExpression ()); + } + + public SelectStatement (FromClause from, IEnumerable<IdentifierExpression> columns) + { + if (from == null) + throw new ArgumentNullException ("from"); + if (columns == null) + throw new ArgumentNullException ("columns"); + + From = from; + this.columns = new List<IdentifierExpression> (); + this.columns.AddRange (columns); + } + + public List<IdentifierExpression> Columns { + get { return columns; } + }
+
+ public FromClause From { + get { return from; } + set { + if (value == null) + throw new ArgumentNullException ("from"); + this.from = value; + } + }
+
+ public WhereClause Where { + get { return where; } + set { where = value; } + }
+
+ public OrderByClause OrderBy { + get { return orderBy; } + set { orderBy = value; } + }
+
+ public GroupByClause GroupBy { + get { return groupBy; } + set { groupBy = value; } + }
+
+ public HavingClause Having { + get { return having; } + set { having = value; } + }
+
+ public UnionClause Union { + get { return union; } + set { union = value; } + } + + public JoinClause Join { + get { return join; } + set { join = value; } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/TruncateStatement.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/TruncateStatement.cs new file mode 100644 index 0000000000..9d2b8a95d8 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/TruncateStatement.cs @@ -0,0 +1,50 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class TruncateStatement : IStatement + { + protected IdentifierExpression identifier; + + public TruncateStatement (IdentifierExpression identifier) + { + Identifier = identifier; + }
+
+ public IdentifierExpression Identifier { + get { return identifier; } + set { + if (value == null) + throw new ArgumentNullException ("identifier"); + identifier = value; + } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/UpdateStatement.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/UpdateStatement.cs new file mode 100644 index 0000000000..6ed1b4d2c8 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Dialect/Statements/UpdateStatement.cs @@ -0,0 +1,72 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public class UpdateStatement : IStatement + { + protected IdentifierExpression identifier; + protected List<IdentifierExpression> columns; + protected List<IExpression> values; + protected WhereClause where; + + public UpdateStatement (IdentifierExpression identifier, IEnumerable<IdentifierExpression> columns, IEnumerable<IExpression> values) + { + Identifier = identifier; + + this.columns = new List<IdentifierExpression> (); + this.values = new List<IExpression> (); + + this.columns.AddRange (columns); + this.values.AddRange (values); + }
+
+ public IdentifierExpression Identifier { + get { return identifier; } + set { + if (value == null) + throw new ArgumentNullException ("identifier"); + identifier = value; + } + }
+
+ public List<IdentifierExpression> Columns { + get { return columns; } + } + + public List<IExpression> Values { + get { return values; } + } + + public WhereClause Where { + get { return where; } + set { where = value; } + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/IDbFactory.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/IDbFactory.cs new file mode 100644 index 0000000000..02e31735d3 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/IDbFactory.cs @@ -0,0 +1,58 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public interface IDbFactory + { + string Identifier { get; } + + string Name { get; } + + ISqlDialect Dialect { get; } + + IConnectionProvider ConnectionProvider { get; } + + IGuiProvider GuiProvider { get; } + + DatabaseConnectionSettings GetDefaultConnectionSettings (); + + IConnectionPool CreateConnectionPool (DatabaseConnectionContext context); + + ISchemaProvider CreateSchemaProvider (IConnectionPool connectionPool); + + SchemaActions GetSupportedActions (string category); + void SetSupportedActions (string category, SchemaActions actions); + bool IsActionSupported (string category, SchemaActions action); + + int GetCapabilities (string category, SchemaActions action); + void SetCapabilities (string category, SchemaActions action, int flags); + bool IsCapabilitySupported (string category, SchemaActions action, Enum capability); + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Makefile.am b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Makefile.am new file mode 100644 index 0000000000..93062b746a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Makefile.am @@ -0,0 +1,168 @@ +ADDIN_BUILD = $(top_builddir)/build/AddIns/MonoDevelop.Database +ASSEMBLY = $(ADDIN_BUILD)/MonoDevelop.Database.Sql.dll +REFS = \ + -r:$(top_builddir)/build/bin/Mono.Addins.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Components.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Core.Gui.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Ide.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Projects.dll \ + -r:$(top_builddir)/build/bin/MonoDevelop.Projects.Gui.dll \ + -r:System \ + -r:System.Data \ + -r:System.Xml + +FILES = \ + AbstractDbFactory.cs \ + Capabilities/CapabilitiesUtility.cs \ + Capabilities/CheckConstraint.cs \ + Capabilities/Column.cs \ + Capabilities/ConnectionSettings.cs \ + Capabilities/ForeignKeyConstraint.cs \ + Capabilities/Index.cs \ + Capabilities/Parameter.cs \ + Capabilities/PrimaryKeyConstraint.cs \ + Capabilities/Procedure.cs \ + Capabilities/SchemaActions.cs \ + Capabilities/Table.cs \ + Capabilities/Trigger.cs \ + Capabilities/UniqueConstraint.cs \ + Capabilities/User.cs \ + Capabilities/View.cs \ + Codons/ActionCodon.cs \ + Codons/CapabilitiesCodon.cs \ + Codons/CapabilityFlagsCodon.cs \ + Codons/DbFactoryCodon.cs \ + Collections/ColumnSchemaCollection.cs \ + Collections/ConstraintSchemaCollection.cs \ + Collections/DatabaseSchemaCollection.cs \ + Collections/DataTypeSchemaCollection.cs \ + Collections/IndexSchemaCollection.cs \ + Collections/IPropertyComparer.cs \ + Collections/ParameterSchemaCollection.cs \ + Collections/ProcedureSchemaCollection.cs \ + Collections/SortedCollectionBase.cs \ + Collections/SortedCollectionItemEventArgs.cs \ + Collections/TableSchemaCollection.cs \ + Collections/TriggerSchemaCollection.cs \ + Collections/UserSchemaCollection.cs \ + Collections/ViewSchemaCollection.cs \ + Configuration/DatabaseConnectionContext.cs \ + Configuration/DatabaseConnectionContextCollection.cs \ + Configuration/DatabaseConnectionContextEventArgs.cs \ + Configuration/DatabaseConnectionSettings.cs \ + Configuration/DatabaseConnectionSettingsCollection.cs \ + ConnectionContextService.cs \ + ConnectionPool/AbstractPooledDbConnection.cs \ + ConnectionPool/DefaultConnectionPool.cs \ + ConnectionPool/FakeConnectionPool.cs \ + ConnectionPool/IConnectionPool.cs \ + ConnectionPool/IPooledDbConnection.cs \ + ConnectionPool/PooledCommand.cs \ + ConnectionPool/PooledDataReader.cs \ + DbFactoryService.cs \ + Dialect/AbstractSqlDialect.cs \ + Dialect/Clauses/FromClause.cs \ + Dialect/Clauses/FromSelectClause.cs \ + Dialect/Clauses/FromTableClause.cs \ + Dialect/Clauses/GroupByClause.cs \ + Dialect/Clauses/HavingClause.cs \ + Dialect/Clauses/IClause.cs \ + Dialect/Clauses/JoinClause.cs \ + Dialect/Clauses/JoinClauseType.cs \ + Dialect/Clauses/OrderByClause.cs \ + Dialect/Clauses/UnionClause.cs \ + Dialect/Clauses/WhereClause.cs \ + Dialect/Expressions/AliasedIdentifierExpression.cs \ + Dialect/Expressions/BooleanExpression.cs \ + Dialect/Expressions/BooleanOperator.cs \ + Dialect/Expressions/IConditionalExpression.cs \ + Dialect/Expressions/IdentifierExpression.cs \ + Dialect/Expressions/IExpression.cs \ + Dialect/Expressions/Operator.cs \ + Dialect/Expressions/OperatorExpression.cs \ + Dialect/Expressions/ParameterExpression.cs \ + Dialect/ISqlDialect.cs \ + Dialect/Literals/BitLiteral.cs \ + Dialect/Literals/BooleanLiteral.cs \ + Dialect/Literals/FalseLiteral.cs \ + Dialect/Literals/HexLiteral.cs \ + Dialect/Literals/ILiteral.cs \ + Dialect/Literals/NullLiteral.cs \ + Dialect/Literals/NumericLiteral.cs \ + Dialect/Literals/StringLiteral.cs \ + Dialect/Literals/TrueLiteral.cs \ + Dialect/Statements/DeleteStatement.cs \ + Dialect/Statements/DropStatement.cs \ + Dialect/Statements/DropStatementType.cs \ + Dialect/Statements/InsertStatement.cs \ + Dialect/Statements/IStatement.cs \ + Dialect/Statements/SelectStatement.cs \ + Dialect/Statements/TruncateStatement.cs \ + Dialect/Statements/UpdateStatement.cs \ + IDbFactory.cs \ + Providers/AbstractConnectionProvider.cs \ + Providers/AbstractSchemaProvider.cs \ + Providers/IConnectionProvider.cs \ + Providers/IGuiProvider.cs \ + Providers/ISchemaProvider.cs \ + QueryService.cs \ + Schema/AbstractSchema.cs \ + Schema/AggregateSchema.cs \ + Schema/CheckConstraintSchema.cs \ + Schema/ColumnSchema.cs \ + Schema/ConstraintSchema.cs \ + Schema/ConstraintType.cs \ + Schema/DatabaseSchema.cs \ + Schema/DataTypeCategory.cs \ + Schema/DataTypeSchema.cs \ + Schema/ForeignKeyAction.cs \ + Schema/ForeignKeyConstraintSchema.cs \ + Schema/GroupSchema.cs \ + Schema/IndexSchema.cs \ + Schema/IndexSortType.cs \ + Schema/IndexType.cs \ + Schema/ISchema.cs \ + Schema/LanguageSchema.cs \ + Schema/OperatorSchema.cs \ + Schema/ParameterSchema.cs \ + Schema/ParameterType.cs \ + Schema/PrimaryKeyConstraintSchema.cs \ + Schema/PrivilegeSchema.cs \ + Schema/ProcedureSchema.cs \ + Schema/Range.cs \ + Schema/RoleSchema.cs \ + Schema/RuleSchema.cs \ + Schema/SchemaSchema.cs \ + Schema/SequenceSchema.cs \ + Schema/TableSchema.cs \ + Schema/TriggerEvent.cs \ + Schema/TriggerFireType.cs \ + Schema/TriggerSchema.cs \ + Schema/TriggerType.cs \ + Schema/UniqueConstraintSchema.cs \ + Schema/UserSchema.cs \ + Schema/ViewSchema.cs + +RES = MonoDevelop.Database.Sql.addin.xml + +if ENABLE_DATABASE +all: $(ASSEMBLY) +else
+all:
+endif + +$(ASSEMBLY): $(FILES) $(build_resources) + mkdir -p $(ADDIN_BUILD) + $(CSC) $(CSC_FLAGS) $(REFS) $(build_resources:%=/resource:%) $(build_sources) -out:$@ -target:library + + +if ENABLE_DATABASE +assemblydir = $(MD_ADDIN_DIR)/MonoDevelop.Database +assembly_DATA = $(ASSEMBLY) +endif + +CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb +EXTRA_DIST = $(FILES) $(RES) + +include $(top_srcdir)/Makefile.include diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/MonoDevelop.Database.Sql.addin.xml b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/MonoDevelop.Database.Sql.addin.xml new file mode 100644 index 0000000000..b3523df591 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/MonoDevelop.Database.Sql.addin.xml @@ -0,0 +1,41 @@ +<Addin id = "Database.Sql" + namespace = "MonoDevelop" + name = "Mono Data Sql" + author = "Christian Hergert, Ben Motmans" + copyright = "MIT X11" + url = "http://www.monodevelop.com" + description = "Database Module" + version = "0.17.0"> + + <Runtime> + <Import assembly="MonoDevelop.Database.Sql.dll"/> + </Runtime> + + <ExtensionPoint path = "/MonoDevelop/Database/Sql" name = "MonoDevelop database providers"> + <Description>MonoDevelop database factory addins.</Description> + <ExtensionNode name="DatabaseFactory" type="MonoDevelop.Database.Sql.DbFactoryCodon"> + <ExtensionNode name="Actions" type="MonoDevelop.Database.Sql.ActionCodon"/> + <ExtensionNode name="Capabilities" type="MonoDevelop.Database.Sql.CapabilitiesCodon"/> + </ExtensionNode> + </ExtensionPoint> + + <ExtensionPoint path = "/MonoDevelop/Database/Capabilities" name = "Capability flags"> + <ExtensionNode name="CapabilityFlags" type="MonoDevelop.Database.Sql.CapabilityFlagsCodon"/> + </ExtensionPoint> + + <Extension path = "/MonoDevelop/Database/Capabilities"> + <CapabilityFlags category="ConnectionSettings" class="MonoDevelop.Database.Sql.ConnectionSettingsCapabilities" /> + <CapabilityFlags category="CheckConstraint" class="MonoDevelop.Database.Sql.CheckConstraintCapabilities" /> + <CapabilityFlags category="TableColumn" class="MonoDevelop.Database.Sql.ColumnCapabilities" /> + <CapabilityFlags category="ForeignKeyConstraint" class="MonoDevelop.Database.Sql.ForeignKeyConstraintCapabilities" /> + <CapabilityFlags category="Index" class="MonoDevelop.Database.Sql.IndexCapabilities" /> + <CapabilityFlags category="Parameter" class="MonoDevelop.Database.Sql.ParameterCapabilities" /> + <CapabilityFlags category="PrimaryKeyConstraint" class="MonoDevelop.Database.Sql.PrimaryKeyConstraintCapabilities" /> + <CapabilityFlags category="Procedure" class="MonoDevelop.Database.Sql.ProcedureCapabilities" /> + <CapabilityFlags category="Table" class="MonoDevelop.Database.Sql.TableCapabilities" /> + <CapabilityFlags category="Trigger" class="MonoDevelop.Database.Sql.TriggerCapabilities" /> + <CapabilityFlags category="UniqueConstraint" class="MonoDevelop.Database.Sql.UniqueConstraintCapabilities" /> + <CapabilityFlags category="View" class="MonoDevelop.Database.Sql.ViewCapabilities" /> + <CapabilityFlags category="User" class="MonoDevelop.Database.Sql.UserCapabilities" /> + </Extension> +</Addin> diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/MonoDevelop.Database.Sql.mdp b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/MonoDevelop.Database.Sql.mdp new file mode 100644 index 0000000000..6eac37e682 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/MonoDevelop.Database.Sql.mdp @@ -0,0 +1,171 @@ +<Project name="MonoDevelop.Database.Sql" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql" /> + <Build debugmode="True" target="Library" /> + <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" /> + </Configuration> + <Configuration name="Release" ctype="DotNetProjectConfiguration"> + <Output directory="../../../build/AddIns/MonoDevelop.Database" assembly="MonoDevelop.Database.Sql" /> + <Build debugmode="False" target="Library" /> + <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" /> + <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="True" ctype="CSharpCompilerParameters" /> + </Configuration> + </Configurations> + <Contents> + <File name="Providers/ISchemaProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="Providers/IConnectionProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/ISchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/AbstractSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/AggregateSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/CheckConstraintSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/ColumnSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/ConstraintSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/DataTypeSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/ForeignKeyConstraintSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/GroupSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/IndexSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/LanguageSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/OperatorSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/ParameterSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/PrimaryKeyConstraintSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/PrivilegeSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/ProcedureSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/RoleSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/RuleSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/SchemaSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/SequenceSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/TableSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/TriggerSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/UniqueConstraintSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/UserSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/ViewSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/DatabaseSchema.cs" subtype="Code" buildaction="Compile" /> + <File name="Providers/AbstractSchemaProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="Codons/DbFactoryCodon.cs" subtype="Code" buildaction="Compile" /> + <File name="MonoDevelop.Database.Sql.addin.xml" subtype="Code" buildaction="EmbedAsResource" /> + <File name="Schema/DataTypeCategory.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/Range.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Statements/SelectStatement.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Statements/InsertStatement.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Statements/DropStatement.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Statements/UpdateStatement.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Statements/DeleteStatement.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Statements/TruncateStatement.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Clauses/WhereClause.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Clauses/FromClause.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Clauses/HavingClause.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Clauses/JoinClause.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Clauses/GroupByClause.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Clauses/OrderByClause.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Clauses/UnionClause.cs" subtype="Code" buildaction="Compile" /> + <File name="IDbFactory.cs" subtype="Code" buildaction="Compile" /> + <File name="DbFactoryService.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/ISqlDialect.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Statements/IStatement.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Expressions/IdentifierExpression.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Expressions/AliasedIdentifierExpression.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Expressions/IExpression.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Clauses/IClause.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Expressions/OperatorExpression.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Expressions/Operator.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Literals/StringLiteral.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Literals/ILiteral.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Literals/HexLiteral.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Literals/NumericLiteral.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Literals/NullLiteral.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Literals/BitLiteral.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Expressions/ParameterExpression.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Literals/TrueLiteral.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Literals/FalseLiteral.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Statements/DropStatementType.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Clauses/FromTableClause.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Clauses/FromSelectClause.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Clauses/JoinClauseType.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Expressions/BooleanExpression.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Expressions/BooleanOperator.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/AbstractSqlDialect.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Expressions/IConditionalExpression.cs" subtype="Code" buildaction="Compile" /> + <File name="Dialect/Literals/BooleanLiteral.cs" subtype="Code" buildaction="Compile" /> + <File name="ConnectionContextService.cs" subtype="Code" buildaction="Compile" /> + <File name="ConnectionPool/IConnectionPool.cs" subtype="Code" buildaction="Compile" /> + <File name="ConnectionPool/IPooledDbConnection.cs" subtype="Code" buildaction="Compile" /> + <File name="ConnectionPool/DefaultConnectionPool.cs" subtype="Code" buildaction="Compile" /> + <File name="ConnectionPool/PooledDataReader.cs" subtype="Code" buildaction="Compile" /> + <File name="ConnectionPool/AbstractPooledDbConnection.cs" subtype="Code" buildaction="Compile" /> + <File name="ConnectionPool/PooledCommand.cs" subtype="Code" buildaction="Compile" /> + <File name="Providers/AbstractConnectionProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="Configuration/DatabaseConnectionSettings.cs" subtype="Code" buildaction="Compile" /> + <File name="Configuration/DatabaseConnectionSettingsCollection.cs" subtype="Code" buildaction="Compile" /> + <File name="Configuration/DatabaseConnectionContext.cs" subtype="Code" buildaction="Compile" /> + <File name="Configuration/DatabaseConnectionContextEventArgs.cs" subtype="Code" buildaction="Compile" /> + <File name="ConnectionPool/FakeConnectionPool.cs" subtype="Code" buildaction="Compile" /> + <File name="QueryService.cs" subtype="Code" buildaction="Compile" /> + <File name="Configuration/DatabaseConnectionContextCollection.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/TriggerType.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/TriggerEvent.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/IndexSortType.cs" subtype="Code" buildaction="Compile" /> + <File name="Collections/TableSchemaCollection.cs" subtype="Code" buildaction="Compile" /> + <File name="Collections/UserSchemaCollection.cs" subtype="Code" buildaction="Compile" /> + <File name="Collections/ViewSchemaCollection.cs" subtype="Code" buildaction="Compile" /> + <File name="Collections/ConstraintSchemaCollection.cs" subtype="Code" buildaction="Compile" /> + <File name="Collections/TriggerSchemaCollection.cs" subtype="Code" buildaction="Compile" /> + <File name="Collections/ProcedureSchemaCollection.cs" subtype="Code" buildaction="Compile" /> + <File name="Collections/ColumnSchemaCollection.cs" subtype="Code" buildaction="Compile" /> + <File name="Collections/ParameterSchemaCollection.cs" subtype="Code" buildaction="Compile" /> + <File name="Collections/SortedCollectionBase.cs" subtype="Code" buildaction="Compile" /> + <File name="Collections/IPropertyComparer.cs" subtype="Code" buildaction="Compile" /> + <File name="Collections/DatabaseSchemaCollection.cs" subtype="Code" buildaction="Compile" /> + <File name="Collections/IndexSchemaCollection.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/ConstraintType.cs" subtype="Code" buildaction="Compile" /> + <File name="Collections/DataTypeSchemaCollection.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/ParameterType.cs" subtype="Code" buildaction="Compile" /> + <File name="Collections/SortedCollectionItemEventArgs.cs" subtype="Code" buildaction="Compile" /> + <File name="Providers/IGuiProvider.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/TriggerFireType.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/IndexType.cs" subtype="Code" buildaction="Compile" /> + <File name="Schema/ForeignKeyAction.cs" subtype="Code" buildaction="Compile" /> + <File name="Capabilities/Table.cs" subtype="Code" buildaction="Compile" /> + <File name="Capabilities/View.cs" subtype="Code" buildaction="Compile" /> + <File name="Capabilities/Procedure.cs" subtype="Code" buildaction="Compile" /> + <File name="Capabilities/PrimaryKeyConstraint.cs" subtype="Code" buildaction="Compile" /> + <File name="Capabilities/ForeignKeyConstraint.cs" subtype="Code" buildaction="Compile" /> + <File name="Capabilities/CheckConstraint.cs" subtype="Code" buildaction="Compile" /> + <File name="Capabilities/UniqueConstraint.cs" subtype="Code" buildaction="Compile" /> + <File name="Capabilities/Trigger.cs" subtype="Code" buildaction="Compile" /> + <File name="Capabilities/Column.cs" subtype="Code" buildaction="Compile" /> + <File name="Capabilities/Parameter.cs" subtype="Code" buildaction="Compile" /> + <File name="Codons/ActionCodon.cs" subtype="Code" buildaction="Compile" /> + <File name="Codons/CapabilityFlagsCodon.cs" subtype="Code" buildaction="Compile" /> + <File name="Capabilities/CapabilitiesUtility.cs" subtype="Code" buildaction="Compile" /> + <File name="Capabilities/ConnectionSettings.cs" subtype="Code" buildaction="Compile" /> + <File name="Capabilities/Index.cs" subtype="Code" buildaction="Compile" /> + <File name="Capabilities/SchemaActions.cs" subtype="Code" buildaction="Compile" /> + <File name="Capabilities/User.cs" subtype="Code" buildaction="Compile" /> + <File name="Codons/CapabilitiesCodon.cs" subtype="Code" buildaction="Compile" /> + <File name="AbstractDbFactory.cs" subtype="Code" buildaction="Compile" /> + <File name="Makefile.am" subtype="Code" buildaction="Nothing" /> + </Contents> + <References> + <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Gac" localcopy="True" refto="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Components" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Ide" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Projects" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Projects.Gui" /> + <ProjectReference type="Project" localcopy="False" refto="MonoDevelop.Core.Gui" /> + <ProjectReference type="Project" localcopy="False" refto="Mono.Addins" /> + </References> + <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am" BuildTargetName="" CleanTargetName="" SyncReferences="True" IsAutotoolsProject="True" RelativeConfigureInPath="../../../"> + <BuildFilesVar Sync="True" Name="FILES" /> + <DeployFilesVar /> + <ResourcesVar Sync="True" Name="RES" /> + <OthersVar /> + <GacRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <AsmRefVar Sync="True" Name="REFS" Prefix="-r:" /> + <ProjectRefVar Sync="True" Name="REFS" Prefix="-r:" /> + </MonoDevelop.Autotools.MakefileInfo> +</Project>
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Providers/AbstractConnectionProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Providers/AbstractConnectionProvider.cs new file mode 100644 index 0000000000..540f1a4d2a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Providers/AbstractConnectionProvider.cs @@ -0,0 +1,73 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Daniel Morgan <danielmorgan@verizon.net>
+// Sureshkumar T <tsureshkumar@novell.com>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data; +using System.Text.RegularExpressions;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public abstract class AbstractConnectionProvider : IConnectionProvider
+ {
+ public abstract IPooledDbConnection CreateConnection (IConnectionPool pool, DatabaseConnectionSettings settings, out string error); +
+ public virtual bool CheckConnection (IPooledDbConnection connection, DatabaseConnectionSettings settings) + { + if (connection.IsOpen) { + IDbConnection conn = connection.DbConnection; + if (conn.Database == settings.Database) { + return true; + } else { + try { + conn.ChangeDatabase (settings.Database); + return true; + } catch { + return false; + } + } + } + return false; + } + + protected virtual string SetConnectionStringParameter (string connectionString, string quoteChar, string parameter, string value) + { + Regex regex = new Regex (parameter + "[ \t]*=[ \t]*" + quoteChar + "([a-zA-Z0-9_.]+)" + quoteChar, RegexOptions.IgnoreCase); + Match match = regex.Match (connectionString); + if (match.Success) { + return connectionString.Substring (0, match.Index) + value + connectionString.Substring (match.Index + match.Length); + } else { + connectionString.TrimEnd (); + return String.Concat (connectionString, + connectionString.EndsWith (";") ? "" : ";", + parameter, "=", quoteChar, value, quoteChar, ";"); + } + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Providers/AbstractSchemaProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Providers/AbstractSchemaProvider.cs new file mode 100644 index 0000000000..2eb48e65f8 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Providers/AbstractSchemaProvider.cs @@ -0,0 +1,837 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System; +using System.Text;
+using System.Data; +using System.Data.Common;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public abstract class AbstractSchemaProvider : ISchemaProvider
+ {
+ protected IConnectionPool connectionPool; + + protected string databasesCollectionString = "Databases"; + protected string tablesCollectionString = "Tables"; + protected string viewsCollectionString = "Views"; + protected string proceduresCollectionString = "Procedures"; + protected string tableColumnsCollectionString = "Columns"; + protected string viewColumnsCollectionString = "ViewColumns"; + protected string procedureParametersCollectionString = "Procedure Parameters"; + protected string usersCollectionString = "Users"; + protected string indexesCollectionString = "Indexes"; + protected string indexColumnsCollectionString = "IndexColumns"; + protected string foreignKeysCollectionString = "Foreign Keys"; + protected string triggersCollectionString = "Triggers"; + protected string dataTypesCollectionString = "DataTypes"; + + protected string[] databaseItemStrings = new string[] { "DATABASE_NAME" }; + protected string[] tableItemStrings = new string[] { "TABLE_SCHEMA", "TABLE_NAME", "TABLE_COMMENT" }; + protected string[] viewItemStrings = new string[] { "TABLE_SCHEMA", "TABLE_NAME", "TABLE_COMMENT" }; + protected string[] procedureItemStrings = new string[] { "ROUTINE_SCHEMA", "ROUTINE_NAME" }; + protected string[] tableColumnItemStrings = new string[] { "COLUMN_NAME", "COLUMN_DEFAULT", "COLUMN_HASDEFAULT", "IS_NULLABLE", "ORDINAL_POSITION", "NUMERIC_PRECISION", "NUMERIC_SCALE", "DATA_TYPE" }; + protected string[] viewColumnItemStrings = new string[] { "COLUMN_NAME" }; + protected string[] procedureParameterItemStrings = new string[] { "PARAMETER_NAME", "DATA_TYPE", "ORDINAL_POSITION", "PARAMETER_MODE" }; + protected string[] userItemStrings = new string[] { "user_name" }; + protected string[] indexItemStrings = new string[] { }; + protected string[] indexColumnItemStrings = new string[] { }; + protected string[] foreignKeyItemStrings = new string[] { }; + protected string[] triggerItemStrings = new string[] { }; + protected string[] dataTypeItemStrings = new string[] { "TypeName", "ColumnSize", "CreateFormat", "CreateParameters", "DataType", "IsAutoIncrementable", "IsFixedLength", "IsNullable", "MaximumScale", "MinimumScale" }; +
+ protected AbstractSchemaProvider (IConnectionPool connectionPool)
+ {
+ if (connectionPool == null)
+ throw new ArgumentNullException ("connectionPool");
+
+ this.connectionPool = connectionPool;
+ }
+
+ public IConnectionPool ConnectionPool {
+ get { return connectionPool; }
+ }
+
+ public virtual DatabaseSchemaCollection GetDatabases ()
+ {
+ DatabaseSchemaCollection collection = new DatabaseSchemaCollection (); + + IPooledDbConnection conn = connectionPool.Request (); + try { + //restrictions: name + DataTable dt = conn.GetSchema (databasesCollectionString); + for (int r = 0; r < dt.Rows.Count; r++) { + DataRow row = dt.Rows[r]; + collection.Add (GetDatabase (row)); + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + + conn.Release (); + + return collection;
+ } + + protected virtual DatabaseSchema GetDatabase (DataRow row) + { + DatabaseSchema schema = new DatabaseSchema (this); + schema.Name = GetRowString (row, databaseItemStrings[0]); + return schema; + }
+
+ public virtual TableSchemaCollection GetTables ()
+ {
+ TableSchemaCollection collection = new TableSchemaCollection (); + + IPooledDbConnection conn = connectionPool.Request (); + try { + //restrictions: database, schema, table, table type + DataTable dt = conn.GetSchema (tablesCollectionString, null, connectionPool.ConnectionContext.ConnectionSettings.Database); + for (int r = 0; r < dt.Rows.Count; r++) { + DataRow row = dt.Rows[r]; + collection.Add (GetTable (row)); + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release (); + + return collection;
+ } + + protected virtual TableSchema GetTable (DataRow row) + { + TableSchema schema = new TableSchema (this); + + schema.SchemaName = GetRowString (row, tableItemStrings[0]); + schema.Name = GetRowString (row, tableItemStrings[1]); + schema.Comment = GetRowString (row, tableItemStrings[2]); + + return schema; + } +
+ public virtual ColumnSchemaCollection GetTableColumns (TableSchema table)
+ {
+ ColumnSchemaCollection collection = new ColumnSchemaCollection (); + + IPooledDbConnection conn = connectionPool.Request (); + //restrictions: database, schema, table, column + try { + DataTable dt = conn.GetSchema (tableColumnsCollectionString, null, table.SchemaName, table.Name); + for (int r = 0; r < dt.Rows.Count; r++) { + DataRow row = dt.Rows[r]; + collection.Add (GetTableColumn (row, table)); + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release (); + + return collection;
+ } + + protected virtual ColumnSchema GetTableColumn (DataRow row, TableSchema table) + { + ColumnSchema schema = new ColumnSchema (this, table); + + schema.SchemaName = table.SchemaName; + schema.Name = GetRowString (row, tableColumnItemStrings[0]); + schema.DefaultValue = GetRowString (row, tableColumnItemStrings[1]); + schema.HasDefaultValue = GetRowBool (row, tableColumnItemStrings[2]); + schema.IsNullable = GetRowBool (row, tableColumnItemStrings[3]); + schema.Position = GetRowInt (row, tableColumnItemStrings[4]); + schema.DataTypeName = GetRowString (row, tableColumnItemStrings[7]); + schema.DataType.ScaleRange.Default = GetRowInt (row, tableColumnItemStrings[6]); + schema.DataType.PrecisionRange.Default = GetRowInt (row, tableColumnItemStrings[5]); + + return schema; + }
+
+ public virtual ViewSchemaCollection GetViews ()
+ {
+ ViewSchemaCollection collection = new ViewSchemaCollection (); + + IPooledDbConnection conn = connectionPool.Request (); + try { + //restrictions: database, schema, table + DataTable dt = conn.GetSchema (viewsCollectionString, null, connectionPool.ConnectionContext.ConnectionSettings.Database); + for (int r = 0; r < dt.Rows.Count; r++) { + DataRow row = dt.Rows[r]; + collection.Add (GetView (row)); + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release (); + + return collection;
+ } + + protected virtual ViewSchema GetView (DataRow row) + { + ViewSchema schema = new ViewSchema (this); + + schema.SchemaName = GetRowString (row, viewItemStrings[0]); + schema.Name = GetRowString (row, viewItemStrings[1]); + schema.Comment = GetRowString (row, viewItemStrings[2]); + + return schema; + }
+
+ public virtual ColumnSchemaCollection GetViewColumns (ViewSchema view)
+ {
+ ColumnSchemaCollection collection = new ColumnSchemaCollection (); + + IPooledDbConnection conn = connectionPool.Request (); + try { + //restrictions: database, schema, table, column + DataTable dt = conn.GetSchema (viewColumnsCollectionString, null, view.SchemaName, view.Name); + for (int r = 0; r < dt.Rows.Count; r++) { + DataRow row = dt.Rows[r]; + collection.Add (GetViewColumn (row, view)); + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release (); + + return collection;
+ } + + protected virtual ColumnSchema GetViewColumn (DataRow row, ViewSchema view) + { + ColumnSchema schema = new ColumnSchema (this, view); + + schema.SchemaName = view.SchemaName; + schema.Name = GetRowString (row, viewColumnItemStrings[0]); + + return schema; + }
+
+ public virtual ProcedureSchemaCollection GetProcedures ()
+ {
+ ProcedureSchemaCollection collection = new ProcedureSchemaCollection (); + + IPooledDbConnection conn = connectionPool.Request (); + try { + //restrictions: database, schema, name, type + DataTable dt = conn.GetSchema (proceduresCollectionString, null, connectionPool.ConnectionContext.ConnectionSettings.Database); + for (int r = 0; r < dt.Rows.Count; r++) { + DataRow row = dt.Rows[r]; + collection.Add (GetProcedure (row)); + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release (); + + return collection;
+ } + + protected virtual ProcedureSchema GetProcedure (DataRow row) + { + ProcedureSchema schema = new ProcedureSchema (this); + + schema.SchemaName = GetRowString (row, procedureItemStrings[0]); + schema.Name = GetRowString (row, procedureItemStrings[1]); + + return schema; + }
+
+ public virtual ParameterSchemaCollection GetProcedureParameters (ProcedureSchema procedure)
+ {
+ ParameterSchemaCollection collection = new ParameterSchemaCollection (); + + IPooledDbConnection conn = connectionPool.Request (); + try { + //restrictions: database, schema, name, type, parameter + DataTable dt = conn.GetSchema (procedureParametersCollectionString, null, procedure.SchemaName, procedure.Name); + for (int r = 0; r < dt.Rows.Count; r++) { + DataRow row = dt.Rows[r]; + collection.Add (GetProcedureParameter (row, procedure)); + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release (); + + return collection;
+ } + + protected virtual ParameterSchema GetProcedureParameter (DataRow row, ProcedureSchema procedure) + { + ParameterSchema schema = new ParameterSchema (this); + + schema.SchemaName = procedure.SchemaName; + schema.Name = GetRowString (row, procedureParameterItemStrings[0]); + schema.DataTypeName = GetRowString (row, procedureParameterItemStrings[1]); + schema.Position = GetRowInt (row, procedureParameterItemStrings[2]); + + string paramType = GetRowString (row, procedureParameterItemStrings[3]); + schema.ParameterType = String.Compare (paramType, "IN", true) == 0 ? + ParameterType.In : (String.Compare (paramType, "OUT", true) == 0 ? + ParameterType.Out : ParameterType.InOut); + + return schema; + }
+
+ public virtual ConstraintSchemaCollection GetTableConstraints (TableSchema table)
+ {
+ ConstraintSchemaCollection collection = new ConstraintSchemaCollection (); + + IPooledDbConnection conn = connectionPool.Request (); + try { + //restrictions: database, schema, table, name + DataTable dt = conn.GetSchema (foreignKeysCollectionString, null, connectionPool.ConnectionContext.ConnectionSettings.Database); + for (int r = 0; r < dt.Rows.Count; r++) { + DataRow row = dt.Rows[r]; + collection.Add (GetTableConstraint (row, table)); + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release (); + + return collection;
+ } + + protected virtual ConstraintSchema GetTableConstraint (DataRow row, TableSchema table) + { + return null; + } + + public virtual ColumnSchemaCollection GetTableIndexColumns (TableSchema table, IndexSchema index)
+ {
+ ColumnSchemaCollection collection = new ColumnSchemaCollection (); + + IPooledDbConnection conn = connectionPool.Request (); + try { + //restrictions: database, schema, table, ConstraintName, column + DataTable dt = conn.GetSchema (indexColumnsCollectionString, null, table.SchemaName, table.Name, index.Name); + for (int r = 0; r < dt.Rows.Count; r++) { + DataRow row = dt.Rows[r]; + collection.Add (GetTableIndexColumn (row, table, index)); + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release (); + + return collection;
+ } + + protected virtual ColumnSchema GetTableIndexColumn (DataRow row, TableSchema table, IndexSchema index) + { + ColumnSchema schema = new ColumnSchema (this, table); + + return schema; + } + + public virtual IndexSchemaCollection GetTableIndexes (TableSchema table)
+ {
+ IndexSchemaCollection collection = new IndexSchemaCollection (); + + IPooledDbConnection conn = connectionPool.Request (); + try { + //restrictions: database, schema, table, name + DataTable dt = conn.GetSchema (indexesCollectionString, null, table.SchemaName, table.Name); + for (int r = 0; r < dt.Rows.Count; r++) { + DataRow row = dt.Rows[r]; + collection.Add (GetTableIndex (row, table)); + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release (); + + return collection;
+ } + + protected virtual IndexSchema GetTableIndex (DataRow row, TableSchema table) + { + IndexSchema schema = new IndexSchema (this); + + return schema; + } + + public virtual ConstraintSchemaCollection GetColumnConstraints (TableSchema table, ColumnSchema column) + { + throw new NotImplementedException (); + } +
+ public virtual UserSchemaCollection GetUsers ()
+ {
+ UserSchemaCollection collection = new UserSchemaCollection (); + + IPooledDbConnection conn = connectionPool.Request (); + try { + //restrictions: name + DataTable dt = conn.GetSchema (usersCollectionString); + for (int r = 0; r < dt.Rows.Count; r++) { + DataRow row = dt.Rows[r]; + collection.Add (GetUser (row)); + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release (); + + return collection;
+ } + + protected virtual UserSchema GetUser (DataRow row) + { + UserSchema schema = new UserSchema (this); + schema.Name = GetRowString (row, userItemStrings[0]); + return schema; + } + + public virtual DataTypeSchemaCollection GetDataTypes ()
+ {
+ DataTypeSchemaCollection collection = new DataTypeSchemaCollection (); + + IPooledDbConnection conn = connectionPool.Request (); + try { + //restrictions: name + DataTable dt = conn.GetSchema (dataTypesCollectionString); + for (int r = 0; r < dt.Rows.Count; r++) { + DataRow row = dt.Rows[r]; + collection.Add (GetDataType (row)); + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + + conn.Release (); + + return collection;
+ } + + protected virtual DataTypeSchema GetDataType (DataRow row) + { + DataTypeSchema schema = new DataTypeSchema (this); + schema.Name = GetRowString (row, dataTypeItemStrings[0]); + schema.LengthRange = new Range (GetRowInt (row, dataTypeItemStrings[1])); + schema.CreateFormat = GetRowString (row, dataTypeItemStrings[2]); + schema.CreateParameters = GetRowString (row, dataTypeItemStrings[3]); + schema.DataType = Type.GetType (GetRowString (row, dataTypeItemStrings[4]), false, false); + schema.IsAutoincrementable = GetRowBool (row, dataTypeItemStrings[5]); + schema.IsFixedLength = GetRowBool (row, dataTypeItemStrings[6]); + schema.IsNullable = GetRowBool (row, dataTypeItemStrings[7]); + schema.ScaleRange = new Range (GetRowInt (row, dataTypeItemStrings[9]), GetRowInt (row, dataTypeItemStrings[8])); + schema.PrecisionRange = new Range (0); + + ProvideDataTypeInformation (schema); + + return schema; + } + + protected virtual void ProvideDataTypeInformation (DataTypeSchema schema) + { + } +
+ public virtual DataTypeSchema GetDataType (string name)
+ { + if (name == null) + throw new ArgumentNullException ("name"); + + DataTypeSchema schema = null; + IPooledDbConnection conn = connectionPool.Request (); + try { + //restrictions: name + DataTable dt = conn.GetSchema (dataTypesCollectionString, name); + if (dt.Rows.Count > 0) + schema = GetDataType (dt.Rows[0]); + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release (); + + return schema;
+ } + + public virtual TriggerSchemaCollection GetTableTriggers (TableSchema table)
+ {
+ TriggerSchemaCollection collection = new TriggerSchemaCollection (); + + IPooledDbConnection conn = connectionPool.Request (); + try { + //restrictions: database, schema, name, EventObjectTable + DataTable dt = conn.GetSchema (triggersCollectionString, null, table.SchemaName, null, table.Name); + for (int r = 0; r < dt.Rows.Count; r++) { + DataRow row = dt.Rows[r]; + collection.Add (GetTableTrigger (row, table)); + } + } catch (Exception e) { + QueryService.RaiseException (e); + } + conn.Release (); + + return collection;
+ } + + protected virtual TriggerSchema GetTableTrigger (DataRow row, TableSchema table) + { + TriggerSchema schema = new TriggerSchema (this); + schema.TableName = table.Name; + + return schema; + } + + public virtual void CreateDatabase (DatabaseSchema database) + { + throw new NotImplementedException (); + } + + public virtual void CreateTable (TableSchema table) + { + string sql = GetTableCreateStatement (table); + ExecuteNonQuery (sql); + } + + public virtual void CreateView (ViewSchema view) + { + throw new NotImplementedException (); + } + + public virtual void CreateProcedure (ProcedureSchema procedure) + { + throw new NotImplementedException (); + } + + public virtual void CreateIndex (IndexSchema index) + { + throw new NotImplementedException (); + } + + public virtual void CreateTrigger (TriggerSchema trigger) + { + throw new NotImplementedException (); + } + + public virtual void CreateUser (UserSchema user) + { + throw new NotImplementedException (); + } + + public virtual void AlterDatabase (DatabaseSchema database) + { + throw new NotImplementedException (); + } + + public virtual void AlterTable (TableSchema table) + { + throw new NotImplementedException (); + } + + public virtual void AlterView (ViewSchema view) + { + throw new NotImplementedException (); + } + + public virtual void AlterProcedure (ProcedureSchema procedure) + { + throw new NotImplementedException (); + } + + public virtual void AlterIndex (IndexSchema index) + { + throw new NotImplementedException (); + } + + public virtual void AlterTrigger (TriggerSchema trigger) + { + throw new NotImplementedException (); + } + + public virtual void AlterUser (UserSchema user) + { + throw new NotImplementedException (); + } + + public virtual void DropDatabase (DatabaseSchema database) + { + throw new NotImplementedException (); + } + + public virtual void DropTable (TableSchema table) + { + throw new NotImplementedException (); + } + + public virtual void DropView (ViewSchema view) + { + throw new NotImplementedException (); + } + + public virtual void DropProcedure (ProcedureSchema procedure) + { + throw new NotImplementedException (); + } + + public virtual void DropIndex (IndexSchema index) + { + throw new NotImplementedException (); + } + + public virtual void DropTrigger (TriggerSchema trigger) + { + throw new NotImplementedException (); + } + + public virtual void DropUser (UserSchema user) + { + throw new NotImplementedException (); + } + + public virtual void RenameDatabase (DatabaseSchema database, string name) + { + throw new NotImplementedException (); + } + + public virtual void RenameTable (TableSchema table, string name) + { + throw new NotImplementedException (); + } + + public virtual void RenameView (ViewSchema view, string name) + { + throw new NotImplementedException (); + } + + public virtual void RenameProcedure (ProcedureSchema procedure, string name) + { + throw new NotImplementedException (); + } + + public virtual void RenameIndex (IndexSchema index, string name) + { + throw new NotImplementedException (); + } + + public virtual void RenameTrigger (TriggerSchema trigger, string name) + { + throw new NotImplementedException (); + } + + public virtual void RenameUser (UserSchema user, string name) + { + throw new NotImplementedException (); + } + + public virtual DatabaseSchema GetNewDatabaseSchema (string name) + { + DatabaseSchema schema = new DatabaseSchema (this); + schema.Name = name; + return schema; + } + + public virtual TableSchema GetNewTableSchema (string name) + { + TableSchema schema = new TableSchema (this, name); + return schema; + } + + public virtual ViewSchema GetNewViewSchema (string name) + { + ViewSchema schema = new ViewSchema (this); + schema.Name = name; + return schema; + } + + public virtual ProcedureSchema GetNewProcedureSchema (string name) + { + ProcedureSchema schema = new ProcedureSchema (this); + schema.Name = name; + return schema; + } + + public virtual ColumnSchema GetNewColumnSchema (string name, ISchema parent) + { + ColumnSchema schema = new ColumnSchema (this, parent, name); + return schema; + } + + public virtual ParameterSchema GetNewParameterSchema (string name) + { + ParameterSchema schema = new ParameterSchema (this); + schema.Name = name; + return schema; + } + + public virtual CheckConstraintSchema GetNewCheckConstraintSchema (string name) + { + CheckConstraintSchema schema = new CheckConstraintSchema (this); + schema.Name = name; + return schema; + } + + public virtual UniqueConstraintSchema GetNewUniqueConstraintSchema (string name) + { + UniqueConstraintSchema schema = new UniqueConstraintSchema (this); + schema.Name = name; + return schema; + } + + public virtual PrimaryKeyConstraintSchema GetNewPrimaryKeyConstraintSchema (string name) + { + PrimaryKeyConstraintSchema schema = new PrimaryKeyConstraintSchema (this); + schema.Name = name; + return schema; + } + + public virtual ForeignKeyConstraintSchema GetNewForeignKeyConstraintSchema (string name) + { + ForeignKeyConstraintSchema schema = new ForeignKeyConstraintSchema (this); + schema.Name = name; + return schema; + } + + public virtual UserSchema GetNewUserSchema (string name) + { + UserSchema schema = new UserSchema (this); + schema.Name = name; + return schema; + } + + public virtual TriggerSchema GetNewTriggerSchema (string name) + { + TriggerSchema schema = new TriggerSchema (this); + schema.Name = name; + return schema; + } + + public virtual string GetTableCreateStatement (TableSchema table) + { + throw new NotImplementedException (); + } + + public virtual string GetTableAlterStatement (TableSchema table) + { + throw new NotImplementedException (); + } + + public virtual string GetViewAlterStatement (ViewSchema view) + { + throw new NotImplementedException (); + } + + public virtual string GetProcedureAlterStatement (ProcedureSchema procedure) + { + throw new NotImplementedException (); + } + + public virtual bool IsValidName (string name) + { + return true; + } + + protected int GetCheckedInt32 (IDataReader reader, int field)
+ {
+ if (reader.IsDBNull (field))
+ return 0;
+
+ object o = reader.GetValue (field); + int res = 0;
+ if (int.TryParse (o.ToString (), out res))
+ return res;
+ return 0;
+ } + + protected string GetCheckedString (IDataReader reader, int field)
+ {
+ if (reader.IsDBNull (field))
+ return null;
+
+ return reader.GetValue (field).ToString ();
+ } + + protected virtual object GetRowObject (DataRow row, string name) + { + try { + return row[name]; + } catch { + return null; + } + } + + protected virtual string GetRowString (DataRow row, string name) + { + try { + return row[name].ToString (); + } catch { + return null; + } + } + + protected virtual int GetRowInt (DataRow row, string name) + { + try { + return (int)row[name]; + } catch { + return 0; + } + } + + protected virtual bool GetRowBool (DataRow row, string name) + { + try { + return (bool)row[name]; + } catch { + return false; + } + } + + protected virtual string GetColumnsString (ColumnSchemaCollection columns, bool includeParens) + { + StringBuilder sb = new StringBuilder (); + bool first = true; + if (includeParens) + sb.Append ("("); + foreach (ColumnSchema column in columns) { + if (first) + first = false; + else + sb.Append (","); + sb.Append (column.Name); + } + if (includeParens) + sb.Append (")"); + return sb.ToString (); + } + + protected virtual int ExecuteNonQuery (string sql) + { + IPooledDbConnection conn = connectionPool.Request (); + int result = conn.ExecuteNonQuery (sql); + conn.Release (); + return result; + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Providers/IConnectionProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Providers/IConnectionProvider.cs new file mode 100644 index 0000000000..31d8bbf3f1 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Providers/IConnectionProvider.cs @@ -0,0 +1,40 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public interface IConnectionProvider
+ { + IPooledDbConnection CreateConnection (IConnectionPool pool, DatabaseConnectionSettings settings, out string error); + + bool CheckConnection (IPooledDbConnection connection, DatabaseConnectionSettings settings);
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Providers/IGuiProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Providers/IGuiProvider.cs new file mode 100644 index 0000000000..63072e4c0c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Providers/IGuiProvider.cs @@ -0,0 +1,44 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System;
+using System.Data;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public interface IGuiProvider + { + bool ShowSelectDatabaseDialog (bool create, out string database); + + bool ShowTableEditorDialog (ISchemaProvider schemaProvider, TableSchema table, bool create); + + bool ShowViewEditorDialog (ISchemaProvider schemaProvider, ViewSchema view, bool create); + + bool ShowProcedureEditorDialog (ISchemaProvider schemaProvider, ProcedureSchema procedure, bool create); + + bool ShowUserEditorDialog (ISchemaProvider schemaProvider, UserSchema user, bool create); + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Providers/ISchemaProvider.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Providers/ISchemaProvider.cs new file mode 100644 index 0000000000..51ca58275c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Providers/ISchemaProvider.cs @@ -0,0 +1,120 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using System.Data;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public interface ISchemaProvider
+ {
+ IConnectionPool ConnectionPool { get; } +
+ DatabaseSchemaCollection GetDatabases (); +
+ TableSchemaCollection GetTables ();
+
+ ColumnSchemaCollection GetTableColumns (TableSchema table);
+
+ ViewSchemaCollection GetViews ();
+
+ ColumnSchemaCollection GetViewColumns (ViewSchema view);
+
+ ProcedureSchemaCollection GetProcedures ();
+
+ ParameterSchemaCollection GetProcedureParameters (ProcedureSchema procedure);
+
+ ConstraintSchemaCollection GetTableConstraints (TableSchema table); + + ConstraintSchemaCollection GetColumnConstraints (TableSchema table, ColumnSchema column); + + IndexSchemaCollection GetTableIndexes (TableSchema table); + + ColumnSchemaCollection GetTableIndexColumns (TableSchema table, IndexSchema index); + + TriggerSchemaCollection GetTableTriggers (TableSchema table);
+
+ UserSchemaCollection GetUsers (); + + DataTypeSchemaCollection GetDataTypes ();
+
+ DataTypeSchema GetDataType (string name); + + void CreateDatabase (DatabaseSchema database); + void CreateTable (TableSchema table); + void CreateView (ViewSchema view); + void CreateProcedure (ProcedureSchema procedure); + void CreateIndex (IndexSchema index); + void CreateTrigger (TriggerSchema trigger); + void CreateUser (UserSchema user); + + void AlterDatabase (DatabaseSchema database); + void AlterTable (TableSchema table); + void AlterView (ViewSchema view); + void AlterProcedure (ProcedureSchema procedure); + void AlterIndex (IndexSchema index); + void AlterTrigger (TriggerSchema trigger); + void AlterUser (UserSchema user); + + void DropDatabase (DatabaseSchema database); + void DropTable (TableSchema table); + void DropView (ViewSchema view); + void DropProcedure (ProcedureSchema procedure); + void DropIndex (IndexSchema index); + void DropTrigger (TriggerSchema trigger); + void DropUser (UserSchema user); + + void RenameDatabase (DatabaseSchema database, string name); + void RenameTable (TableSchema table, string name); + void RenameView (ViewSchema view, string name); + void RenameProcedure (ProcedureSchema procedure, string name); + void RenameIndex (IndexSchema index, string name); + void RenameTrigger (TriggerSchema trigger, string name); + void RenameUser (UserSchema user, string name); + + string GetTableCreateStatement (TableSchema table); + string GetTableAlterStatement (TableSchema table); + string GetViewAlterStatement (ViewSchema view); + string GetProcedureAlterStatement (ProcedureSchema procedure); + + DatabaseSchema GetNewDatabaseSchema (string name); + TableSchema GetNewTableSchema (string name); + ViewSchema GetNewViewSchema (string name); + ProcedureSchema GetNewProcedureSchema (string name); + ColumnSchema GetNewColumnSchema (string name, ISchema parent); + ParameterSchema GetNewParameterSchema (string name); + CheckConstraintSchema GetNewCheckConstraintSchema (string name); + UniqueConstraintSchema GetNewUniqueConstraintSchema (string name); + PrimaryKeyConstraintSchema GetNewPrimaryKeyConstraintSchema (string name); + ForeignKeyConstraintSchema GetNewForeignKeyConstraintSchema (string name); + UserSchema GetNewUserSchema (string name); + TriggerSchema GetNewTriggerSchema (string name); + + bool IsValidName (string name);
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/QueryService.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/QueryService.cs new file mode 100644 index 0000000000..b222253b97 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/QueryService.cs @@ -0,0 +1,124 @@ +// +// Authors: +// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (C) 2005 Christian Hergert
+// Copyright (c) 2007 Ben Motmans +//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+// + +using System; +using System.Data; +using System.Threading; +using System.Collections.Generic; +using Mono.Addins; +using MonoDevelop.Database.Sql; +using MonoDevelop.Core; +using MonoDevelop.Core.Gui; + +namespace MonoDevelop.Database.Sql +{ + public delegate void DatabaseConnectionContextCallback (DatabaseConnectionContext context, bool connected, object state); + + public static class QueryService + { + public static void RaiseException (Exception exception) + { + Services.MessageService.ShowError (exception); + LoggingService.LogError ("Database Exception", exception); + } + + public static void RaiseException (string message, Exception exception) + { + Services.MessageService.ShowError (exception, message); + LoggingService.LogError ("Database Exception", exception); + } + + //TODO: show errors + public static void EnsureConnection (DatabaseConnectionContext context, DatabaseConnectionContextCallback callback, object state) + { + if (context == null) + throw new ArgumentNullException ("context"); + if (callback == null) + throw new ArgumentNullException ("callback"); + + IConnectionPool pool = context.ConnectionPool; + if (pool.IsInitialized) { + callback (context, true, state); + return; + } + + IDbFactory fac = DbFactoryService.GetDbFactory (context.ConnectionSettings); + bool requiresPassword = fac.GetCapabilities ("ConnectionSettings", SchemaActions.Schema) == (int)ConnectionSettingsCapabilities.Password; + + if (!context.ConnectionSettings.SavePassword && String.IsNullOrEmpty (context.ConnectionSettings.Password) && requiresPassword) { + string password = Services.MessageService.GetPassword ( + GettextCatalog.GetString ("Please enter the password for connection '{0}'", + context.ConnectionSettings.Name), + GettextCatalog.GetString ("Enter Password") + ); + + if (password == null) { + callback (context, false, state); + return; + } else { + context.ConnectionSettings.Password = password; + } + } + + EnsureConnectionState internalState = new EnsureConnectionState (context, callback, state); + ThreadPool.QueueUserWorkItem (new WaitCallback (EnsureConnectionThreaded), internalState); + } + + private static void EnsureConnectionThreaded (object obj) + { + EnsureConnectionState internalState = obj as EnsureConnectionState; + IConnectionPool pool = internalState.ConnectionContext.ConnectionPool; + + try { + bool connected = pool.Initialize (); + DispatchService.GuiDispatch (delegate () { + internalState.Callback (internalState.ConnectionContext, connected, internalState.State); + }); + } catch (Exception e) { + LoggingService.LogDebug (e.ToString ()); + + DispatchService.GuiDispatch (delegate () { + internalState.Callback (internalState.ConnectionContext, false, internalState.State); + }); + } + } + } + + internal class EnsureConnectionState + { + public object State; + public DatabaseConnectionContext ConnectionContext; + public DatabaseConnectionContextCallback Callback; + + public EnsureConnectionState (DatabaseConnectionContext context, DatabaseConnectionContextCallback callback, object state) + { + ConnectionContext = context; + Callback = callback; + State = state; + } + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/AbstractSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/AbstractSchema.cs new file mode 100644 index 0000000000..9dab91e8e7 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/AbstractSchema.cs @@ -0,0 +1,176 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public abstract class AbstractSchema : ISchema
+ {
+ public event EventHandler Changed;
+
+ protected string name;
+ protected string ownerName;
+ protected string comment;
+ protected string definition;
+ protected string schema;
+ protected ISchemaProvider provider;
+
+ protected AbstractSchema (ISchemaProvider schemaProvider)
+ {
+ if (schemaProvider == null)
+ throw new ArgumentNullException ("schemaProvider");
+
+ this.provider = schemaProvider;
+ } + + protected AbstractSchema (AbstractSchema schema)
+ {
+ if (schema == null)
+ throw new ArgumentNullException ("schema");
+
+ this.provider = schema.provider; + this.name = schema.name; + this.ownerName = schema.ownerName; + this.comment = schema.comment; + this.definition = schema.definition; + this.schema = schema.schema;
+ }
+
+ public virtual string Name {
+ get {
+ return name;
+ }
+ set {
+ if (name != value) {
+ name = value;
+ OnChanged ();
+ }
+ }
+ }
+
+ public virtual string FullName {
+ get {
+ if (!String.IsNullOrEmpty (schema))
+ return schema + "." + name;
+ else
+ return name;
+ }
+ }
+
+ public virtual string SchemaName {
+ get {
+ return schema;
+ }
+ set {
+ if (schema != value) {
+ schema = value;
+ OnChanged();
+ }
+ }
+ }
+
+ public virtual SchemaSchema Schema {
+ get {
+ throw new NotImplementedException();
+ }
+ set {
+ if (value != null)
+ schema = value.Name;
+ else
+ schema = null;
+ }
+ }
+
+ public virtual string Comment {
+ get {
+ return comment;
+ }
+ set {
+ if (comment != value) {
+ comment = value;
+ OnChanged ();
+ }
+ }
+ }
+
+ public virtual string Definition {
+ get {
+ return definition;
+ }
+ set {
+ if (definition != value) {
+ definition = value;
+ OnChanged ();
+ }
+ }
+ }
+
+ public ISchemaProvider SchemaProvider {
+ get { return provider; }
+ }
+
+ public virtual string OwnerName {
+ get {
+ return ownerName;
+ }
+ set {
+ if (ownerName != value) {
+ ownerName = value;
+ OnChanged ();
+ }
+ }
+ }
+
+ public virtual UserSchema Owner {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+
+ public virtual ICollection<PrivilegeSchema> Privileges {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+
+ public virtual void OnChanged()
+ {
+ if (Changed != null)
+ Changed (this, EventArgs.Empty);
+ }
+
+ public virtual void Refresh()
+ {
+ } + + public abstract object Clone ();
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/AggregateSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/AggregateSchema.cs new file mode 100644 index 0000000000..d0e1670fb2 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/AggregateSchema.cs @@ -0,0 +1,55 @@ +//
+// Schema/AggregateSchema.cs
+//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class AggregateSchema : AbstractSchema
+ {
+ public AggregateSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ {
+ } + + public AggregateSchema (AggregateSchema schema)
+ : base (schema)
+ {
+ }
+
+ public override string ToString()
+ {
+ return Name + "()";
+ } + + public override object Clone () + { + return new AggregateSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/CheckConstraintSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/CheckConstraintSchema.cs new file mode 100644 index 0000000000..a65a4b03d0 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/CheckConstraintSchema.cs @@ -0,0 +1,58 @@ +//
+// Schema/CheckConstraintSchema.cs
+//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class CheckConstraintSchema : ConstraintSchema
+ { + protected string source; +
+ public CheckConstraintSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider, ConstraintType.Check)
+ {
+ } + + public CheckConstraintSchema (CheckConstraintSchema constraint) + : base (constraint) + { + source = constraint.source; + } + + public string Source { + get { return source; } + set { source = value; } + } + + public override object Clone () + { + return new CheckConstraintSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ColumnSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ColumnSchema.cs new file mode 100644 index 0000000000..e6d5dc8d42 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ColumnSchema.cs @@ -0,0 +1,151 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class ColumnSchema : AbstractSchema
+ { + protected ISchema parent;
+ protected string dataType = String.Empty; + protected bool hasDefaultValue;
+ protected string defaultValue;
+ protected bool nullable;
+ protected int position = 0; + protected ConstraintSchemaCollection constraints;
+
+ public ColumnSchema (ISchemaProvider schemaProvider, ISchema parent)
+ : base (schemaProvider)
+ { + this.parent = parent;
+ } + + public ColumnSchema (ISchemaProvider schemaProvider, ISchema parent, string name)
+ : base (schemaProvider)
+ { + this.constraints = new ConstraintSchemaCollection (); + this.parent = parent; + this.name = name;
+ } + + public ColumnSchema (ColumnSchema column) + : base (column) + { + parent = column.parent; //do not clone, this would create an infinite loop + dataType = column.dataType; + hasDefaultValue = column.hasDefaultValue; + defaultValue = column.defaultValue; + nullable = column.nullable; + position = column.position; + constraints = new ConstraintSchemaCollection (column.constraints); + } + + public ISchema Parent {
+ get { return parent; }
+ set {
+ if (parent != value) {
+ parent = value;
+ OnChanged ();
+ }
+ }
+ }
+
+ public DataTypeSchema DataType {
+ get { return SchemaProvider.GetDataType (dataType); }
+ }
+
+ public string DataTypeName {
+ get { return dataType; }
+ set {
+ if (dataType != value) {
+ dataType = value;
+ OnChanged ();
+ }
+ }
+ }
+
+ public virtual string DefaultValue {
+ get { return defaultValue; }
+ set {
+ if (defaultValue != value) {
+ defaultValue = value;
+ OnChanged();
+ }
+ }
+ } + + public virtual bool HasDefaultValue {
+ get { return hasDefaultValue; }
+ set {
+ if (hasDefaultValue != value) {
+ hasDefaultValue = value;
+ OnChanged();
+ }
+ }
+ }
+
+ public virtual bool IsNullable {
+ get { return nullable; }
+ set {
+ if (nullable != value) {
+ nullable = value;
+ OnChanged();
+ }
+ }
+ }
+
+ public virtual int Position {
+ get { return position; }
+ set {
+ if (position != value) {
+ position = value;
+ OnChanged();
+ }
+ }
+ } + + public ConstraintSchemaCollection Constraints {
+ get {
+ if (constraints == null)
+ constraints = provider.GetColumnConstraints (parent as TableSchema, this);
+ return constraints;
+ }
+ } + + public override void Refresh()
+ {
+ constraints = null;
+ } + + public override object Clone () + { + return new ColumnSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ConstraintSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ConstraintSchema.cs new file mode 100644 index 0000000000..3841099572 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ConstraintSchema.cs @@ -0,0 +1,68 @@ +//
+// Schema/ConstraintSchema.cs
+//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System; +using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public abstract class ConstraintSchema : AbstractSchema
+ {
+ protected ColumnSchemaCollection columns; + protected bool isColumnConstraint; + protected ConstraintType constraintType;
+
+ protected ConstraintSchema (ISchemaProvider schemaProvider, ConstraintType constraintType)
+ : base (schemaProvider)
+ { + columns = new ColumnSchemaCollection (); + this.constraintType = constraintType;
+ } + + protected ConstraintSchema (ConstraintSchema constraint) + : base (constraint) + { + isColumnConstraint = constraint.isColumnConstraint; + constraintType = constraint.constraintType; + }
+ public ColumnSchemaCollection Columns {
+ get { return columns; }
+ } + + public bool IsColumnConstraint {
+ get { return isColumnConstraint; } + set { isColumnConstraint = value; }
+ } + + public ConstraintType ConstraintType {
+ get { return constraintType; }
+ }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ConstraintType.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ConstraintType.cs new file mode 100644 index 0000000000..e30ccc2a54 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ConstraintType.cs @@ -0,0 +1,43 @@ +//
+// Schema/ConstraintSchema.cs
+//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System; +using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public enum ConstraintType
+ {
+ Unique, + Check, + PrimaryKey, + ForeignKey
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/DataTypeCategory.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/DataTypeCategory.cs new file mode 100644 index 0000000000..d4d4792ca8 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/DataTypeCategory.cs @@ -0,0 +1,105 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
namespace MonoDevelop.Database.Sql
+{
+ public enum DataTypeCategory
+ {
+ /// <summary>
+ /// Used to define a column with a start value and a seed
+ /// </summary>
+ AutoNumber,
+ /// <summary>
+ /// Data type allowing only 2 possibilities, like: true/false, 1/0, ...
+ /// </summary>
+ Boolean, + /// <summary>
+ /// Data type allowing to store individual bits, length will be shown in bits instead of bytes
+ /// </summary>
+ Bit,
+ /// <summary>
+ /// Used for all numerical values without a comma (int, long, ...)
+ /// </summary>
+ Integer,
+ /// <summary>
+ /// Used for all floating point values (float, double, ...)
+ /// </summary>
+ Float,
+ /// <summary>
+ /// Single-byte fixed length text, padding is used when the inserted text is smaller then the stored text
+ /// </summary>
+ Char,
+ /// <summary>
+ /// Single-byte text, the length is not defined and can be variable
+ /// </summary>
+ VarChar,
+ /// <summary>
+ /// Multi-byte (unicode) fixed length text, padding is used when the inserted text is smaller then the stored text
+ /// </summary>
+ NChar,
+ /// <summary>
+ /// Multi-byte (unicode text, the length is not defined and can be variable
+ /// </summary>
+ NVarChar,
+ /// <summary>
+ /// Binary objects, like blob, clob, image, ... with a fixed length
+ /// </summary>
+ Binary,
+ /// <summary>
+ /// Binary objects, like blob, clob, image, ... with variable length
+ /// </summary>
+ VarBinary,
+ /// <summary>
+ /// Globally unique identifier, can be similar like the .NET System.Guid type
+ /// </summary>
+ Uid,
+ /// <summary>
+ /// Date field
+ /// </summary>
+ Date,
+ /// <summary>
+ /// Time field
+ /// </summary>
+ Time, + /// <summary>
+ /// TimeStamp field
+ /// </summary>
+ TimeStamp,
+ /// <summary>
+ /// Field containing both a date and a time
+ /// </summary>
+ DateTime, + /// <summary>
+ /// Special text containing XML chunks
+ /// </summary> + Xml,
+ /// <summary>
+ /// Undefined data type
+ /// </summary>
+ Other
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/DataTypeSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/DataTypeSchema.cs new file mode 100644 index 0000000000..fa72131401 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/DataTypeSchema.cs @@ -0,0 +1,241 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class DataTypeSchema : AbstractSchema
+ {
+ protected bool isComplex; + protected bool isNullable; + protected bool isAutoincrementable; + protected bool isFixedLength;
+
+ protected DataTypeCategory category; + protected Type dataType; + + protected string createFormat; + protected string createParameters;
+
+ protected Range lengthRange;
+ protected Range precisionRange;
+ protected Range scaleRange;
+
+ public DataTypeSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ { + lengthRange = new Range (0); + precisionRange = new Range (0); + scaleRange = new Range (0);
+ } + + public DataTypeSchema (DataTypeSchema dt)
+ : base (dt)
+ { + this.isComplex = dt.isComplex; + this.isNullable = dt.isNullable; + this.isAutoincrementable = dt.isAutoincrementable; + this.isFixedLength = dt.isFixedLength; + this.category = dt.category; + this.dataType = dt.dataType; + this.createFormat = dt.createFormat; + this.createParameters = dt.createParameters; + this.lengthRange = new Range (dt.lengthRange); + this.precisionRange = new Range (dt.precisionRange); + this.scaleRange = new Range (dt.scaleRange);
+ }
+
+ public DataTypeCategory DataTypeCategory {
+ get { return category; }
+ set {
+ if (category != value) {
+ category = value;
+ OnChanged ();
+ }
+ }
+ }
+
+ public bool HasRange {
+ get { return precisionRange != null; }
+ }
+
+ public bool HasScale {
+ get { return scaleRange != null; }
+ }
+
+ public Range LengthRange {
+ get { return lengthRange; }
+ set {
+ if (lengthRange != value) {
+ lengthRange = value;
+ OnChanged ();
+ }
+ }
+ }
+
+ public Range PrecisionRange {
+ get { return precisionRange; }
+ set {
+ if (precisionRange != value) {
+ precisionRange = value;
+ OnChanged ();
+ }
+ }
+ }
+
+ public Range ScaleRange {
+ get { return scaleRange; }
+ set {
+ if (scaleRange != value) {
+ scaleRange = value;
+ OnChanged ();
+ }
+ }
+ }
+
+ public bool IsComplex {
+ get { return isComplex; }
+ set {
+ if (isComplex != value) {
+ isComplex = value;
+ OnChanged();
+ }
+ }
+ } + + public bool IsNullable {
+ get { return isNullable; }
+ set {
+ if (isNullable != value) {
+ isNullable = value;
+ OnChanged();
+ }
+ }
+ } + + public bool IsAutoincrementable {
+ get { return isAutoincrementable; }
+ set {
+ if (isAutoincrementable != value) {
+ isAutoincrementable = value;
+ OnChanged();
+ }
+ }
+ } + + public bool IsFixedLength {
+ get { return isFixedLength; }
+ set {
+ if (isFixedLength != value) {
+ isFixedLength = value;
+ OnChanged();
+ }
+ }
+ } + + public Type DataType {
+ get { return dataType; }
+ set {
+ if (dataType != value) {
+ dataType = value;
+ OnChanged();
+ }
+ }
+ } + + public string CreateFormat {
+ get { return createFormat; }
+ set {
+ if (createFormat != value) {
+ createFormat = value;
+ OnChanged();
+ }
+ }
+ } + + public string CreateParameters {
+ get { return createParameters; }
+ set {
+ if (createParameters != value) {
+ createParameters = value;
+ OnChanged();
+ }
+ }
+ }
+
+ public ColumnSchemaCollection Columns {
+ get {
+ if (isComplex == false) {
+ return new ColumnSchemaCollection ();
+ } else {
+ // TODO: Get complex columns from the provider
+ throw new NotImplementedException();
+ }
+ }
+ } + + public virtual string GetCreateString (ColumnSchema column) + { + if (createFormat == null) { + return name; + } else { + if (createParameters != null) { + string[] parameters = createParameters.Split (','); + string[] chunks = new string[parameters.Length]; + + int index=0; + foreach (string param in parameters) { + string chunk = param.ToLower ().Trim (); + + if (chunk.Contains ("length") || chunk.Contains ("size")) { + chunks[index] = column.DataType.LengthRange.Default.ToString (); + } else if (chunk.Contains ("scale")) { + chunks[index] = column.DataType.ScaleRange.Default.ToString (); + } else if (chunk.Contains ("precision")) { + chunks[index] = column.DataType.PrecisionRange.Default.ToString (); + } else { + chunks[index] = String.Empty; + } + index++; + } + + return String.Format (System.Globalization.CultureInfo.InvariantCulture, createFormat, chunks); + } + + return createFormat; + } + } + + public override object Clone () + { + return new DataTypeSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/DatabaseSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/DatabaseSchema.cs new file mode 100644 index 0000000000..b92f59754d --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/DatabaseSchema.cs @@ -0,0 +1,52 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+
+namespace MonoDevelop.Database.Sql
+{
+ /// <summary>
+ /// SQL schema object representing a database
+ /// </summary>
+ public class DatabaseSchema : AbstractSchema
+ {
+ public DatabaseSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ {
+ } + + public DatabaseSchema (DatabaseSchema schema)
+ : base (schema)
+ {
+ } + + public override object Clone () + { + return new DatabaseSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ForeignKeyAction.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ForeignKeyAction.cs new file mode 100644 index 0000000000..4607c35592 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ForeignKeyAction.cs @@ -0,0 +1,41 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public enum ForeignKeyAction + { + None, + Cascade, + Restrict, + NoAction, + SetDefault, + SetNull + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ForeignKeyConstraintSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ForeignKeyConstraintSchema.cs new file mode 100644 index 0000000000..5aa219da99 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ForeignKeyConstraintSchema.cs @@ -0,0 +1,103 @@ +//
+// Schema/ForeignKeyConstraintSchema.cs
+//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System; +using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class ForeignKeyConstraintSchema : ConstraintSchema
+ {
+ protected string referenceTable; + protected ColumnSchemaCollection referenceColumns; + protected ForeignKeyAction deleteAction; + protected ForeignKeyAction updateAction;
+
+ public ForeignKeyConstraintSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider, ConstraintType.ForeignKey)
+ { + referenceColumns = new ColumnSchemaCollection ();
+ } + + public ForeignKeyConstraintSchema (ForeignKeyConstraintSchema constraint) + : base (constraint) + { + referenceTable = constraint.referenceTable; + referenceColumns = new ColumnSchemaCollection (constraint.referenceColumns); + deleteAction = constraint.deleteAction; + updateAction = constraint.updateAction; + } + + public string ReferenceTableName {
+ get { return referenceTable; }
+ set { + if (referenceTable != value) {
+ referenceTable = value;
+ OnChanged(); + }
+ }
+ }
+
+ public TableSchema ReferenceTable {
+ get { throw new NotImplementedException(); }
+ set {
+ referenceTable = value.FullName;
+ OnChanged();
+ }
+ } + + public ForeignKeyAction DeleteAction {
+ get { return deleteAction; }
+ set { + if (deleteAction != value) {
+ deleteAction = value;
+ OnChanged(); + }
+ }
+ } + + public ForeignKeyAction UpdateAction {
+ get { return updateAction; }
+ set { + if (updateAction != value) {
+ updateAction = value;
+ OnChanged(); + }
+ }
+ }
+
+ public ColumnSchemaCollection ReferenceColumns {
+ get { return referenceColumns; }
+ } + + public override object Clone () + { + return new ForeignKeyConstraintSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/GroupSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/GroupSchema.cs new file mode 100644 index 0000000000..41b750999e --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/GroupSchema.cs @@ -0,0 +1,63 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class GroupSchema : AbstractSchema
+ {
+ public GroupSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ {
+ } + + public GroupSchema (GroupSchema schema)
+ : base (schema)
+ {
+ }
+
+ public UserSchema Users {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public ICollection<RoleSchema> Roles {
+ get {
+ throw new NotImplementedException ();
+ }
+ } + + public override object Clone () + { + return new GroupSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ISchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ISchema.cs new file mode 100644 index 0000000000..1e5e76e9f3 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ISchema.cs @@ -0,0 +1,97 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public interface ISchema : ICloneable
+ {
+ /// <summary>
+ /// Event fired when the object is changed.
+ /// </summary>
+ event EventHandler Changed;
+
+ /// <summary>
+ /// SQL object name.
+ /// </summary>
+ string Name { get; set; }
+
+ /// <summary>
+ /// Full name of the object. This is typically `schema.objectname'.
+ /// </summary>
+ string FullName { get; }
+
+ /// <summary>
+ /// SQL Comment associated with this object.
+ /// </summary>
+ string Comment { get; set; }
+
+ /// <summary>
+ /// SQL Syntax Definition of this object.
+ /// </summary>
+ string Definition { get; set; }
+
+ /// <summary>
+ /// Name of schema
+ /// </summary>
+ string SchemaName { get; set; }
+
+ /// <summary>
+ /// Schema object representing the schema this object is part of.
+ /// </summary>
+ SchemaSchema Schema { get; set; }
+
+ /// <summary>
+ /// Set the owners name in the database by the literal string name
+ /// of the user.
+ /// </summary>
+ string OwnerName { get; set; }
+
+ /// <summary>
+ /// Owner of this sql object.
+ /// </summary>
+ UserSchema Owner { get; }
+
+ /// <summary>
+ /// Privileges (sometimes known as ACL's) associated with this object.
+ /// </summary>
+ ICollection<PrivilegeSchema> Privileges { get; }
+
+ /// <summary>
+ /// The connection provider associated with this SQL object.
+ /// </summary>
+ ISchemaProvider SchemaProvider { get; }
+
+ /// <summary>
+ /// Refresh the object from the database.
+ /// </summary>
+ void Refresh();
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/IndexSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/IndexSchema.cs new file mode 100644 index 0000000000..0bc09f8c6a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/IndexSchema.cs @@ -0,0 +1,82 @@ +//
+// Schema/IndexConstraintSchema.cs
+//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class IndexSchema : AbstractSchema
+ { + protected string tableName; + protected IndexType type; + protected ColumnSchemaCollection columns; //TODO: create col subclass, to include sort order and length +
+ public IndexSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ { + columns = new ColumnSchemaCollection ();
+ } + + public IndexSchema (IndexSchema index)
+ : base (index)
+ { + this.tableName = index.tableName; + this.type = index.type; + this.columns = index.columns;
+ } + + public string TableName {
+ get { return tableName; }
+ set {
+ if (tableName != value) {
+ tableName = value;
+ OnChanged ();
+ }
+ }
+ } + + public IndexType IndexType {
+ get { return type; }
+ set {
+ if (type != value) {
+ type = value;
+ OnChanged ();
+ }
+ }
+ } + + public ColumnSchemaCollection Columns {
+ get { return columns; }
+ } + + public override object Clone () + { + return new IndexSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/IndexSortType.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/IndexSortType.cs new file mode 100644 index 0000000000..05c37ebb1b --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/IndexSortType.cs @@ -0,0 +1,37 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public enum IndexSortType + { + Ascending, + Descending + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/IndexType.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/IndexType.cs new file mode 100644 index 0000000000..a9a744cd43 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/IndexType.cs @@ -0,0 +1,37 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public enum IndexType + { + Btree, + Hash + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/LanguageSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/LanguageSchema.cs new file mode 100644 index 0000000000..25e6540355 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/LanguageSchema.cs @@ -0,0 +1,63 @@ +//
+// Schema/PrimaryKeyConstraintSchema.cs
+//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class LanguageSchema : AbstractSchema
+ {
+ protected string handler = null;
+
+ public LanguageSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ {
+ } + + public LanguageSchema (LanguageSchema lang)
+ : base (lang)
+ { + this.handler = lang.handler;
+ }
+
+ public ProcedureSchema Handler {
+ get {
+ // TODO: Get procedure
+ throw new NotImplementedException();
+ }
+ set {
+ handler = value.FullName;
+ }
+ } + + public override object Clone () + { + return new LanguageSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/OperatorSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/OperatorSchema.cs new file mode 100644 index 0000000000..7e06ebd3ad --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/OperatorSchema.cs @@ -0,0 +1,68 @@ +//
+// Schema/OperatorSchema.cs
+//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class OperatorSchema : AbstractSchema
+ {
+ protected string leftDataType = null;
+ protected string rightDataType = null;
+
+ public OperatorSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ {
+ } + + public OperatorSchema (OperatorSchema op)
+ : base (op)
+ { + this.leftDataType = op.leftDataType; + this.rightDataType = op.rightDataType;
+ }
+ + //TODO:
+ public DataTypeSchema LeftDataType {
+ get {
+ throw new NotImplementedException();
+ }
+ set {
+ if (value != null)
+ leftDataType = value.Name;
+ else
+ leftDataType = String.Empty;
+ }
+ } + + public override object Clone () + { + return new OperatorSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ParameterSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ParameterSchema.cs new file mode 100644 index 0000000000..8d16bf513c --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ParameterSchema.cs @@ -0,0 +1,91 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class ParameterSchema : AbstractSchema
+ {
+ protected string dataType; + protected ParameterType paramType; + protected int position;
+
+ public ParameterSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ {
+ } + + public ParameterSchema (ParameterSchema param)
+ : base (param)
+ { + this.dataType = param.dataType; + this.paramType = param.paramType; + this.position = param.position;
+ }
+
+ public DataTypeSchema DataType {
+ get { return provider.GetDataType (dataType); }
+ } + + public string DataTypeName {
+ get { return dataType; }
+ set {
+ if (dataType != value) {
+ dataType = value;
+ OnChanged ();
+ }
+ }
+ } + + public ParameterType ParameterType {
+ get { return paramType; }
+ set {
+ if (paramType != value) {
+ paramType = value;
+ OnChanged();
+ }
+ }
+ } + + public virtual int Position {
+ get { return position; }
+ set {
+ if (position != value) {
+ position = value;
+ OnChanged();
+ }
+ }
+ } + + public override object Clone () + { + return new ParameterSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ParameterType.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ParameterType.cs new file mode 100644 index 0000000000..48746127a8 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ParameterType.cs @@ -0,0 +1,38 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public enum ParameterType + { + In, + Out, + InOut + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/PrimaryKeyConstraintSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/PrimaryKeyConstraintSchema.cs new file mode 100644 index 0000000000..7cf09c837a --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/PrimaryKeyConstraintSchema.cs @@ -0,0 +1,50 @@ +//
+// Schema/PrimaryKeyConstraintSchema.cs
+//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class PrimaryKeyConstraintSchema : ConstraintSchema
+ {
+ public PrimaryKeyConstraintSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider, ConstraintType.PrimaryKey)
+ {
+ } + + public PrimaryKeyConstraintSchema (PrimaryKeyConstraintSchema constraint) + : base (constraint) + { + } + + public override object Clone () + { + return new PrimaryKeyConstraintSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/PrivilegeSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/PrivilegeSchema.cs new file mode 100644 index 0000000000..a9f7fc7af8 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/PrivilegeSchema.cs @@ -0,0 +1,64 @@ +//
+// Schema/PrivilegeSchema.cs
+//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class PrivilegeSchema : AbstractSchema
+ { + //TODO: grantee? + which role??
+ protected bool canGrant = false;
+
+ public PrivilegeSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ {
+ } + + public PrivilegeSchema (PrivilegeSchema priv)
+ : base (priv)
+ { + this.canGrant = priv.canGrant;
+ }
+
+ public bool CanGrant {
+ get { return canGrant; }
+ set { + if (canGrant != value) {
+ canGrant = value;
+ OnChanged(); + }
+ }
+ } + + public override object Clone () + { + return new PrivilegeSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ProcedureSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ProcedureSchema.cs new file mode 100644 index 0000000000..08853732b6 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ProcedureSchema.cs @@ -0,0 +1,99 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class ProcedureSchema : AbstractSchema
+ {
+ protected ParameterSchemaCollection parameters;
+ protected string language;
+ protected bool isSystemProcedure = false;
+
+ public ProcedureSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ {
+ } + + public ProcedureSchema (ProcedureSchema proc)
+ : base (proc)
+ { + this.parameters = new ParameterSchemaCollection (parameters); + this.language = proc.language; + this.isSystemProcedure = proc.isSystemProcedure;
+ }
+
+ public ParameterSchemaCollection Parameters {
+ get {
+ if (parameters == null)
+ parameters = provider.GetProcedureParameters (this);
+ return parameters;
+ }
+ }
+
+ public LanguageSchema Language {
+ get {
+ throw new NotImplementedException();
+ }
+ set {
+ language = value.FullName;
+ }
+ }
+
+ public string LanguageName {
+ get {
+ return language;
+ }
+ set {
+ if (language != value) {
+ language = value;
+ OnChanged ();
+ }
+ }
+ }
+
+ public bool IsSystemProcedure {
+ get {
+ return isSystemProcedure;
+ }
+ set {
+ if (isSystemProcedure != value) {
+ isSystemProcedure = value;
+ OnChanged ();
+ }
+ }
+ } + + public override object Clone () + { + return new ProcedureSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/Range.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/Range.cs new file mode 100644 index 0000000000..1217687bbd --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/Range.cs @@ -0,0 +1,91 @@ +//
+// Authors:
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
namespace MonoDevelop.Database.Sql
+{
+ public class Range
+ {
+ private int min;
+ private int max; + private int defaultValue;
+
+ public Range (int min, int max)
+ {
+ Max = max; + Min = min;
+ }
+
+ public Range (int constRange)
+ : this (constRange, constRange, constRange)
+ {
+ } + + public Range (int min, int max, int defaultValue) + : this (min, max)
+ {
+ this.defaultValue = defaultValue;
+ } + + public Range (Range range) + : this (range.Min, range.Max, range.Default)
+ {
+ }
+
+ public int Min {
+ get { return min; } + set { + min = value; + if (min > max) + max = min; + }
+ }
+
+
+ public int Max {
+ get { return max; } + set { + max = value; + if (max < min) + min = max; + }
+ } + + public int Default {
+ get { return defaultValue; } + set { defaultValue = value; }
+ }
+
+ public bool IsInRange (int value)
+ {
+ return value >= min && value <= max;
+ }
+
+ public bool IsFixed {
+ get { return min == max; }
+ }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/RoleSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/RoleSchema.cs new file mode 100644 index 0000000000..4d0f7ae8d0 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/RoleSchema.cs @@ -0,0 +1,53 @@ +//
+// Schema/RoleSchema.cs
+//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class RoleSchema : AbstractSchema
+ {
+// TODO: Should include a list of Privileges to object mappings. Also
+// needs to include what Identity this Role is connected to. IE: Group
+// or user.
+ public RoleSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ {
+ } + + public RoleSchema (RoleSchema role)
+ : base (role)
+ {
+ } + + public override object Clone () + { + return new RoleSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/RuleSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/RuleSchema.cs new file mode 100644 index 0000000000..51e0c10043 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/RuleSchema.cs @@ -0,0 +1,50 @@ +//
+// Schema/RuleSchema.cs
+//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class RuleSchema : AbstractSchema
+ {
+ public RuleSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ {
+ } + + public RuleSchema (RuleSchema rule)
+ : base (rule)
+ {
+ } + + public override object Clone () + { + return new RuleSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/SchemaSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/SchemaSchema.cs new file mode 100644 index 0000000000..6d34cb639d --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/SchemaSchema.cs @@ -0,0 +1,59 @@ +//
+// Schema/SchemaSchema.cs
+//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class SchemaSchema : AbstractSchema
+ { + //TODO:
+ public SchemaSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ {
+ } + + public SchemaSchema (SchemaSchema schema)
+ : base (schema)
+ {
+ }
+
+ public override SchemaSchema Schema {
+ get {
+ return null;
+ }
+ set {
+ }
+ } + + public override object Clone () + { + return new SchemaSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/SequenceSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/SequenceSchema.cs new file mode 100644 index 0000000000..278e6e9cc0 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/SequenceSchema.cs @@ -0,0 +1,99 @@ +//
+// Schema/SequenceSchema.cs
+//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class SequenceSchema : AbstractSchema
+ {
+ protected string minValue;
+ protected string maxValue;
+ protected string currentValue;
+ protected string increment;
+
+ public SequenceSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ {
+ } + + public SequenceSchema (SequenceSchema seq)
+ : base (seq)
+ { + this.minValue = seq.minValue; + this.maxValue = seq.maxValue; + this.currentValue = seq.currentValue; + this.increment = seq.increment;
+ }
+
+ public string MinValue {
+ get { return minValue; }
+ set { + if (minValue != value) {
+ minValue = value;
+ OnChanged(); + }
+ }
+ }
+
+ public string MaxValue {
+ get { return maxValue; }
+ set { + if (maxValue != value) {
+ maxValue = value;
+ OnChanged(); + }
+ }
+ }
+
+ public string CurrentValue {
+ get { return currentValue; }
+ set { + if (currentValue != value) {
+ currentValue = value;
+ OnChanged(); + }
+ }
+ }
+
+ public string Increment {
+ get { return increment; }
+ set { + if (increment != value) {
+ increment = value;
+ OnChanged(); + }
+ }
+ } + + public override object Clone () + { + return new SequenceSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/TableSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/TableSchema.cs new file mode 100644 index 0000000000..1fc9d084fa --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/TableSchema.cs @@ -0,0 +1,159 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ /// <summary>
+ /// SQL schema object representing a table
+ /// </summary>
+ public class TableSchema : AbstractSchema
+ { + //TODO: support for inherited table schemas +
+ protected bool isSystemTable = false;
+ protected string tableSpaceName;
+
+ protected ColumnSchemaCollection columns;
+ protected ConstraintSchemaCollection constraints; + protected TriggerSchemaCollection triggers;
+
+ public TableSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ {
+ } + + public TableSchema (ISchemaProvider schemaProvider, string name)
+ : base (schemaProvider)
+ { + Name = name; + + columns = new ColumnSchemaCollection (); + constraints = new ConstraintSchemaCollection (); + triggers = new TriggerSchemaCollection ();
+ } + + public TableSchema (TableSchema table) + : base (table) + { + isSystemTable = table.isSystemTable; + tableSpaceName = table.tableSpaceName; + columns = new ColumnSchemaCollection (table.columns); + constraints = new ConstraintSchemaCollection (table.constraints); + triggers = new TriggerSchemaCollection (table.triggers); + }
+
+ /// <summary>
+ /// Is this table part of the database core
+ /// </summary>
+ public bool IsSystemTable {
+ get {
+ return isSystemTable;
+ }
+ set {
+ isSystemTable = value;
+ OnChanged ();
+ }
+ }
+
+ public string TableSpaceName {
+ get {
+ return tableSpaceName;
+ }
+ set {
+ tableSpaceName = value;
+ OnChanged ();
+ }
+ }
+
+ /// <summary>
+ /// Override ToString() to show the tables FullName
+ /// <remarks>
+ /// Returns 'schema.tablename'
+ /// </remarks>
+ /// </summary>
+ public override string ToString ()
+ {
+ return FullName;
+ }
+
+ /// <summary>
+ /// Collection of columns associated with this table.
+ /// </summary>
+ public ColumnSchemaCollection Columns {
+ get {
+ if (columns == null)
+ columns = provider.GetTableColumns(this);
+ return columns;
+ }
+ }
+
+ /// <summary>
+ /// Collection of constraints associated with this table.
+ /// </summary>
+ public ConstraintSchemaCollection Constraints {
+ get {
+ if (constraints == null)
+ constraints = provider.GetTableConstraints(this);
+ return constraints;
+ }
+ } + + public TriggerSchemaCollection Triggers {
+ get {
+ if (triggers == null)
+ triggers = provider.GetTableTriggers(this);
+ return triggers;
+ }
+ }
+
+ /// <summary>
+ /// Refresh the information associated with this table.
+ /// </summary>
+ public override void Refresh()
+ {
+ // TODO: Update Name, etc.
+ columns = null;
+ constraints = null; + triggers = null;
+ definition = null;
+ } + + public override object Clone () + { + TableSchema clone = new TableSchema (this); + if (clone.columns != null) { + foreach (ColumnSchema column in clone.columns) + column.Parent = clone; + } + return clone; + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/TriggerEvent.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/TriggerEvent.cs new file mode 100644 index 0000000000..5dae4408d4 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/TriggerEvent.cs @@ -0,0 +1,39 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + [Flags] + public enum TriggerEvent + { + Insert, + Update, + Delete + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/TriggerFireType.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/TriggerFireType.cs new file mode 100644 index 0000000000..8124ab1a11 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/TriggerFireType.cs @@ -0,0 +1,37 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public enum TriggerFireType + { + ForEachRow, + ForEachStatement + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/TriggerSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/TriggerSchema.cs new file mode 100644 index 0000000000..d6c77e4acb --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/TriggerSchema.cs @@ -0,0 +1,137 @@ +//
+// Schema/TriggerSchema.cs
+//
+// Authors:
+// Christian Hergert <chris@mosaix.net> +// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc. +// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class TriggerSchema : AbstractSchema
+ { + protected string tableName; + protected TriggerType triggerType; + protected TriggerFireType triggerFireType; + protected TriggerEvent triggerEvent; + protected int position; + protected bool isActive; + protected string source; +
+ public TriggerSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ {
+ } + + public TriggerSchema (TriggerSchema trigger)
+ : base (trigger)
+ { + tableName = trigger.tableName; + triggerType = trigger.triggerType; + triggerFireType = trigger.triggerFireType; + triggerEvent = trigger.triggerEvent; + position = trigger.position; + isActive = trigger.isActive; + source = trigger.source;
+ } + + public string TableName {
+ get { return tableName; }
+ set {
+ if (tableName != value) {
+ tableName = value;
+ OnChanged ();
+ }
+ }
+ } + + public TriggerType TriggerType { + get { return triggerType; } + set { + if (triggerType != value) {
+ triggerType = value;
+ OnChanged ();
+ } + } + } + + public TriggerFireType TriggerFireType { + get { return triggerFireType; } + set { + if (triggerFireType != value) {
+ triggerFireType = value;
+ OnChanged ();
+ } + } + } + + public TriggerEvent TriggerEvent { + get { return triggerEvent; } + set { + if (triggerEvent != value) {
+ triggerEvent = value;
+ OnChanged ();
+ } + } + } + + public int Position { + get { return position; } + set { + if (position != value) {
+ position = value;
+ OnChanged ();
+ } + } + } + + public bool IsActive { + get { return isActive; } + set { + if (isActive != value) {
+ isActive = value;
+ OnChanged ();
+ } + } + } + + public string Source {
+ get { return source; }
+ set {
+ if (source != value) {
+ source = value;
+ OnChanged ();
+ }
+ }
+ } + + public override object Clone () + { + return new TriggerSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/TriggerType.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/TriggerType.cs new file mode 100644 index 0000000000..bbc21dfdf8 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/TriggerType.cs @@ -0,0 +1,37 @@ +// +// Authors: +// Ben Motmans <ben.motmans@gmail.com> +// +// Copyright (c) 2007 Ben Motmans +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Data; +using System.Collections.Generic; + +namespace MonoDevelop.Database.Sql +{ + public enum TriggerType + { + Before, + After + } +}
\ No newline at end of file diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/UniqueConstraintSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/UniqueConstraintSchema.cs new file mode 100644 index 0000000000..7ccb6932d1 --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/UniqueConstraintSchema.cs @@ -0,0 +1,50 @@ +//
+// Schema/UniqueConstraintSchema.cs
+//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class UniqueConstraintSchema : ConstraintSchema
+ {
+ public UniqueConstraintSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider, ConstraintType.Unique)
+ {
+ } + + public UniqueConstraintSchema (UniqueConstraintSchema constraint) + : base (constraint) + { + } + + public override object Clone () + { + return new UniqueConstraintSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/UserSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/UserSchema.cs new file mode 100644 index 0000000000..54b78720cc --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/UserSchema.cs @@ -0,0 +1,96 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class UserSchema : AbstractSchema
+ {
+ protected string userId;
+ protected string password;
+ protected DateTime expires = DateTime.MinValue; + + //TODO: list of allowed hosts?
+
+ public UserSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ {
+ } + + public UserSchema (UserSchema user)
+ : base (user)
+ { + this.userId = user.userId; + this.password = user.password; + this.expires = user.expires;
+ }
+
+ public virtual ICollection<RoleSchema> Roles {
+ get {
+ throw new NotImplementedException();
+ }
+ }
+
+ public virtual string UserId {
+ get { return userId; }
+ set { + if (userId != value) {
+ userId = value; + OnChanged (); + }
+ }
+ }
+
+ public virtual string Password {
+ get { return password; }
+ set {
+ if (password != value) {
+ password = value; + OnChanged (); + }
+ }
+ }
+
+ public virtual DateTime Expires {
+ get { return expires; }
+ set {
+ if (expires != value) {
+ expires = value; + OnChanged (); + }
+ }
+ } + + public override object Clone () + { + return new UserSchema (this); + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ViewSchema.cs b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ViewSchema.cs new file mode 100644 index 0000000000..41612193bc --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.Sql/Schema/ViewSchema.cs @@ -0,0 +1,102 @@ +//
+// Authors:
+// Christian Hergert <chris@mosaix.net>
+// Ben Motmans <ben.motmans@gmail.com>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (c) 2007 Ben Motmans
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System; +using System.Collections.Generic;
+
+namespace MonoDevelop.Database.Sql
+{
+ public class ViewSchema : AbstractSchema
+ {
+ protected bool isSystemView = false; + protected string statement; + protected ColumnSchemaCollection columns;
+
+ public ViewSchema (ISchemaProvider schemaProvider)
+ : base (schemaProvider)
+ {
+ } + + public ViewSchema (ViewSchema view)
+ : base (view)
+ { + this.isSystemView = view.isSystemView; + this.statement = view.statement; + this.columns = new ColumnSchemaCollection (view.columns);
+ }
+
+ public bool IsSystemView {
+ get { return isSystemView; }
+ set { + if (isSystemView != value) {
+ isSystemView = value;
+ OnChanged(); + }
+ }
+ } + + public string Statement {
+ get { return statement; }
+ set { + if (statement != value) {
+ statement = value;
+ OnChanged(); + }
+ }
+ } + + /// <summary>
+ /// Collection of columns associated with this view.
+ /// </summary>
+ public ColumnSchemaCollection Columns {
+ get {
+ if (columns == null)
+ columns = provider.GetViewColumns(this);
+ return columns;
+ }
+ }
+
+ /// <summary>
+ /// Refresh the information associated with this view.
+ /// </summary>
+ public override void Refresh()
+ {
+ definition = null;
+ } + + public override object Clone () + { + ViewSchema clone = new ViewSchema (this); + if (clone.columns != null) { + foreach (ColumnSchema column in clone.columns) + column.Parent = clone; + } + return clone; + }
+ }
+}
diff --git a/extras/MonoDevelop.Database/MonoDevelop.Database.mds b/extras/MonoDevelop.Database/MonoDevelop.Database.mds new file mode 100644 index 0000000000..88df59334b --- /dev/null +++ b/extras/MonoDevelop.Database/MonoDevelop.Database.mds @@ -0,0 +1,68 @@ +<Combine name="MonoDevelop.Database" fileversion="2.0" outputpath="build/bin/"> + <Configurations active="Debug"> + <Configuration name="Debug" ctype="CombineConfiguration"> + <Entry build="True" name="MonoDevelop.Database.Sql" configuration="Debug" /> + <Entry build="False" name="MonoDevelop.Database.Sql.Tests" configuration="Debug" /> + <Entry build="True" name="MonoDevelop.Database.Query" configuration="Debug" /> + <Entry build="False" name="MonoDevelop.Database.Sql.Sybase" configuration="Debug" /> + <Entry build="True" name="MonoDevelop.Database.Sql.MySql" configuration="Debug" /> + <Entry build="False" name="MonoDevelop.Database.Sql.Firebird" configuration="Debug" /> + <Entry build="True" name="MonoDevelop.Database.Sql.SqlServer" configuration="Debug" /> + <Entry build="True" name="MonoDevelop.Database.Sql.Sqlite" configuration="Debug" /> + <Entry build="False" name="MonoDevelop.Database.Sql.Oracle" configuration="Debug" /> + <Entry build="True" name="MonoDevelop.Database.Sql.Npgsql" configuration="Debug" /> + <Entry build="False" name="MonoDevelop.Database.Sql.Odbc" configuration="Debug" /> + <Entry build="True" name="MonoDevelop.Database.ConnectionManager" configuration="Debug" /> + <Entry build="True" name="MonoDevelop.Database.Components" configuration="Debug" /> + <Entry build="True" name="MonoDevelop.Database.Designer" configuration="Debug" /> + </Configuration> + <Configuration name="Release" ctype="CombineConfiguration"> + <Entry build="True" name="MonoDevelop.Database.Sql" configuration="Release" /> + <Entry build="True" name="MonoDevelop.Database.Sql.Tests" configuration="Release" /> + <Entry build="True" name="MonoDevelop.Database.Query" configuration="Release" /> + <Entry build="True" name="MonoDevelop.Database.Sql.Sybase" configuration="Release" /> + <Entry build="True" name="MonoDevelop.Database.Sql.MySql" configuration="Release" /> + <Entry build="True" name="MonoDevelop.Database.Sql.Firebird" configuration="Release" /> + <Entry build="True" name="MonoDevelop.Database.Sql.SqlServer" configuration="Release" /> + <Entry build="True" name="MonoDevelop.Database.Sql.Sqlite" configuration="Release" /> + <Entry build="True" name="MonoDevelop.Database.Sql.Oracle" configuration="Release" /> + <Entry build="True" name="MonoDevelop.Database.Sql.Npgsql" configuration="Release" /> + <Entry build="True" name="MonoDevelop.Database.Sql.Odbc" configuration="Release" /> + <Entry build="True" name="MonoDevelop.Database.ConnectionManager" configuration="Release" /> + <Entry build="True" name="MonoDevelop.Database.Components" configuration="Release" /> + <Entry build="True" name="MonoDevelop.Database.Designer" configuration="Release" /> + </Configuration> + </Configurations> + <StartMode startupentry="MonoDevelop.Database.Sql.Tests" single="False"> + <Execute type="None" entry="MonoDevelop.Database.Sql" /> + <Execute type="None" entry="MonoDevelop.Database.Sql.Tests" /> + <Execute type="None" entry="MonoDevelop.Database.Components" /> + <Execute type="None" entry="MonoDevelop.Database.Query" /> + <Execute type="None" entry="MonoDevelop.Database.Designer" /> + <Execute type="None" entry="MonoDevelop.Database.ConnectionManager" /> + <Execute type="None" entry="MonoDevelop.Database.Sql.Sybase" /> + <Execute type="None" entry="MonoDevelop.Database.Sql.MySql" /> + <Execute type="None" entry="MonoDevelop.Database.Sql.Firebird" /> + <Execute type="None" entry="MonoDevelop.Database.Sql.SqlServer" /> + <Execute type="None" entry="MonoDevelop.Database.Sql.Sqlite" /> + <Execute type="None" entry="MonoDevelop.Database.Sql.Oracle" /> + <Execute type="None" entry="MonoDevelop.Database.Sql.Npgsql" /> + <Execute type="None" entry="MonoDevelop.Database.Sql.Odbc" /> + </StartMode> + <Entries> + <Entry filename="MonoDevelop.Database.Sql/MonoDevelop.Database.Sql.mdp" /> + <Entry filename="MonoDevelop.Database.Sql.Tests/MonoDevelop.Database.Sql.Tests.mdp" /> + <Entry filename="MonoDevelop.Database.Query/MonoDevelop.Database.Query.mdp" /> + <Entry filename="MonoDevelop.Database.Sql.Sybase/MonoDevelop.Database.Sql.Sybase.mdp" /> + <Entry filename="MonoDevelop.Database.Sql.MySql/MonoDevelop.Database.Sql.MySql.mdp" /> + <Entry filename="MonoDevelop.Database.Sql.Firebird/MonoDevelop.Database.Sql.Firebird.mdp" /> + <Entry filename="MonoDevelop.Database.Sql.SqlServer/MonoDevelop.Database.Sql.SqlServer.mdp" /> + <Entry filename="MonoDevelop.Database.Sql.Sqlite/MonoDevelop.Database.Sql.Sqlite.mdp" /> + <Entry filename="MonoDevelop.Database.Sql.Oracle/MonoDevelop.Database.Sql.Oracle.mdp" /> + <Entry filename="MonoDevelop.Database.Sql.Npgsql/MonoDevelop.Database.Sql.Npgsql.mdp" /> + <Entry filename="MonoDevelop.Database.Sql.Odbc/MonoDevelop.Database.Sql.Odbc.mdp" /> + <Entry filename="MonoDevelop.Database.ConnectionManager/MonoDevelop.Database.ConnectionManager.mdp" /> + <Entry filename="MonoDevelop.Database.Components/MonoDevelop.Database.Components.mdp" /> + <Entry filename="MonoDevelop.Database.Designer/MonoDevelop.Database.Designer.mdp" /> + </Entries> +</Combine>
\ No newline at end of file |