* Makefile.am:
[monodevelop.git] / extras / MonoDevelop.Database / MonoDevelop.Database.Sql.Sqlite / SqliteGuiProvider.cs
blob5cfb296599a9e94677f1356a71f84946d85a0243
1 //
2 // Authors:
3 // Ben Motmans <ben.motmans@gmail.com>
4 //
5 // Copyright (c) 2007 Ben Motmans
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
14 // The above copyright notice and this permission notice shall be included in
15 // all copies or substantial portions of the Software.
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 // THE SOFTWARE.
26 using Gtk;
27 using System;
28 using System.Data;
29 using System.Collections.Generic;
30 using MonoDevelop.Core;
31 using MonoDevelop.Database.Designer;
32 using MonoDevelop.Database.Components;
33 namespace MonoDevelop.Database.Sql.Sqlite
35 public class SqliteGuiProvider : IGuiProvider
37 // public bool ShowSelectDatabaseDialog (bool create, out string database)
38 // {
39 // FileChooserDialog dlg = null;
40 // if (create) {
41 // dlg = new FileChooserDialog (
42 // AddinCatalog.GetString ("Save Database"), null, FileChooserAction.Save,
43 // "gtk-cancel", ResponseType.Cancel,
44 // "gtk-save", ResponseType.Accept
45 // );
46 // } else {
47 // dlg = new FileChooserDialog (
48 // AddinCatalog.GetString ("Open Database"), null, FileChooserAction.Open,
49 // "gtk-cancel", ResponseType.Cancel,
50 // "gtk-open", ResponseType.Accept
51 // );
52 // }
53 // dlg.SelectMultiple = false;
54 // dlg.LocalOnly = true;
55 // dlg.Modal = true;
56 //
57 // FileFilter filter = new FileFilter ();
58 // filter.AddMimeType ("application/x-sqlite2");
59 // filter.AddMimeType ("application/x-sqlite3");
60 // filter.AddPattern ("*.db");
61 // filter.Name = AddinCatalog.GetString ("SQLite databases");
62 // FileFilter filterAll = new FileFilter ();
63 // filterAll.AddPattern ("*");
64 // filterAll.Name = AddinCatalog.GetString ("All files");
65 // dlg.AddFilter (filter);
66 // dlg.AddFilter (filterAll);
68 // if (dlg.Run () == (int)ResponseType.Accept) {
69 // database = dlg.Filename;
70 // dlg.Destroy ();
71 // return true;
72 // } else {
73 // dlg.Destroy ();
74 // database = null;
75 // return false;
76 // }
77 // }
79 public bool ShowCreateDatabaseDialog (IDbFactory factory)
81 return RunDialog (new SqliteCreateDatabaseDialog (factory));
84 public bool ShowAddConnectionDialog (IDbFactory factory)
86 return RunDialog (new SqliteDatabaseConnectionSettingsDialog (factory));
89 public bool ShowEditConnectionDialog (IDbFactory factory, DatabaseConnectionSettings settings)
91 return RunDialog (new SqliteDatabaseConnectionSettingsDialog (factory, settings));
94 public bool ShowTableEditorDialog (IEditSchemaProvider schemaProvider, TableSchema table, bool create)
96 TableEditorSettings settings = new TableEditorSettings ();
97 TableEditorDialog dlg = new TableEditorDialog (schemaProvider, create, settings);
98 dlg.Initialize (table);
100 return RunDialog (dlg);
103 public bool ShowViewEditorDialog (IEditSchemaProvider schemaProvider, ViewSchema view, bool create)
105 ViewEditorSettings settings = new ViewEditorSettings ();
106 ViewEditorDialog dlg = new ViewEditorDialog (schemaProvider, create, settings);
107 dlg.Initialize (view);
109 return RunDialog (dlg);
112 public bool ShowProcedureEditorDialog (IEditSchemaProvider schemaProvider, ProcedureSchema procedure, bool create)
114 ProcedureEditorSettings settings = new ProcedureEditorSettings ();
115 ProcedureEditorDialog dlg = new ProcedureEditorDialog (schemaProvider, create, settings);
116 dlg.Initialize (procedure);
118 return RunDialog (dlg);
121 public bool ShowUserEditorDialog (IEditSchemaProvider schemaProvider, UserSchema user, bool create)
123 return false; //TODO: implement ShowUserEditorDialog
126 private bool RunDialog (Dialog dlg)
128 bool result = false;
129 try {
130 if (dlg.Run () == (int)ResponseType.Ok)
131 result = true;
132 } finally {
133 dlg.Destroy ();
135 return result;