Exemplo n.º 1
0
        public TableEditorDialog(IEditSchemaProvider schemaProvider, bool create, TableEditorSettings settings)
        {
            if (schemaProvider == null)
            {
                throw new ArgumentNullException("schemaProvider");
            }

            this.schemaProvider = schemaProvider;
            this.action         = create ? SchemaActions.Create : SchemaActions.Alter;
            this.settings       = settings;

            this.Build();

            if (create)
            {
                Title = AddinCatalog.GetString("Create Table");
            }
            else
            {
                Title = AddinCatalog.GetString("Alter Table");
            }

            notebook = new Notebook();
            vboxContent.PackStart(notebook, true, true, 0);

            notebook.Sensitive = false;
            ThreadPool.QueueUserWorkItem(new WaitCallback(InitializeThreaded));
            vboxContent.ShowAll();
        }
		public CheckConstraintEditorWidget (ISchemaProvider schemaProvider, SchemaActions action, CheckConstraintEditorSettings settings)
		{
			if (settings == null)
				throw new ArgumentNullException ("settings");
			if (schemaProvider == null)
				throw new ArgumentNullException ("schemaProvider");
			
			this.schemaProvider = schemaProvider;
			this.settings = settings;
			this.action = action;
			
			this.Build();

			store = new ListStore (typeof (string), typeof (string), typeof (bool), typeof (string), typeof (object));

			listCheck.Model = store;

			TreeViewColumn colName = new TreeViewColumn ();
			TreeViewColumn colColumn = new TreeViewColumn ();
			TreeViewColumn colIsColumnConstraint = new TreeViewColumn ();
			
			colName.Title = AddinCatalog.GetString ("Name");
			colColumn.Title = AddinCatalog.GetString ("Column");
			colIsColumnConstraint.Title = AddinCatalog.GetString ("Column Constraint");
			
			colColumn.MinWidth = 120; //request a bigger width
			
			CellRendererText nameRenderer = new CellRendererText ();
			columnRenderer = new CellRendererCombo ();
			CellRendererToggle isColumnConstraintRenderer = new CellRendererToggle ();

			nameRenderer.Editable = true;
			nameRenderer.Edited += new EditedHandler (NameEdited);
			
			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);

			listCheck.AppendColumn (colName);
			if (settings.SupportsColumnConstraints)
				listCheck.AppendColumn (colColumn);
			if (settings.SupportsColumnConstraints && settings.SupportsTableConstraints)
				listCheck.AppendColumn (colIsColumnConstraint);
			
			listCheck.Selection.Changed += new EventHandler (OnSelectionChanged);
			sqlEditor.TextChanged += new EventHandler (SourceChanged);

			ShowAll ();
		}
Exemplo n.º 3
0
        public static async Task BeginDownloadDatasets()
        {
            // Download first page and check meta
            Console.WriteLine("Fetching datasets\n---------------------------------------");
            databases = PostgresHelpers.QuandlDatabaseActions.GetImportedDatabases();

            Console.WriteLine("\nSelected databases:");
            databases.ForEach(db =>
                              Console.WriteLine(" -[DB] " + db.Name + " - " + db.DatabaseCode)
                              );
            Console.WriteLine();

            // Prepare schema:
            // Make datasets model tables
            SchemaActions.CreateQuandlDatasetTable();
            Console.WriteLine();

            int count = 0;

            foreach (QuandlDatabase database in databases)
            {
                // Starting 0%
                pagesSum = 0;
                count++;

                // Each database -> gives a bunch of datasets of its own kind
                // So this is called a new group
                datasetsGroups.Add(new QuandlDatasetGroup()
                {
                    DatabaseCode = database.DatabaseCode, Datasets = new List <QuandlDataset>()
                });

                //Utils.ConsoleInformer.PrintProgress("1B", "Fetching datasets [" + database.DatabaseCode + "]: ", "0%");

                // Get first datasets page ordered
                var datasetsReponse = DownloadDataset(1, database);

                // Download remaining datasets
                if (datasetsReponse.Meta.TotalPages >= 2)
                {
                    await DownloadDatasetsAsync(2, datasetsReponse.Meta.TotalPages, database);
                }
                //DownloadDatasetsParallel(2, datasetsReponse.Meta.TotalPages, database);

                Utils.ConsoleInformer.InformSimple("[DB] " + database.DatabaseCode + " Done. [" + count + "/" + databases.Count + "]");
                Utils.ConsoleInformer.InformSimple("-------------------------------------");
            }

            // Check errors
            if (errors.Count > 0)
            {
                Utils.ConsoleInformer.Inform("Some unexpected stuff happened. See the log for more info");
            }

            // Manipulate data into database
            //Console.WriteLine("\nInserting data into database\n---------------------------------------");

            // Make datasets list
            //PostgresHelpers.QuandlDatasetActions.InsertQuandlDatasets(datasetsGroups);
        }
Exemplo n.º 4
0
        protected override void Read(NodeElement elem)
        {
            base.Read(elem);

            actions     = (SchemaActions)Enum.Parse(typeof(SchemaActions), action);
            parsedFlags = CapabilitiesUtility.Parse(category, flags);
        }
Exemplo n.º 5
0
		protected override void Read (NodeElement elem)
		{
			base.Read (elem);
			
			actions = (SchemaActions)Enum.Parse (typeof (SchemaActions), action);
			parsedFlags = CapabilitiesUtility.Parse (category, flags);
		}
		public UniqueConstraintEditorWidget (ISchemaProvider schemaProvider, SchemaActions action)
		{
			if (schemaProvider == null)
				throw new ArgumentNullException ("schemaProvider");
			
			this.schemaProvider = schemaProvider;
			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 ();

			colName.Title = AddinCatalog.GetString ("Name");
			
			CellRendererText nameRenderer = new CellRendererText ();
			
			nameRenderer.Editable = true;
			nameRenderer.Edited += new EditedHandler (NameEdited);
			
			colName.PackStart (nameRenderer, true);
			colName.AddAttribute (nameRenderer, "text", colNameIndex);
			
			listUnique.AppendColumn (colName);
			
			ShowAll ();
		}
        public PrimaryKeyConstraintEditorWidget(ISchemaProvider schemaProvider, SchemaActions action)
        {
            if (schemaProvider == null)
            {
                throw new ArgumentNullException("schemaProvider");
            }

            this.schemaProvider = schemaProvider;
            this.action         = action;

            this.Build();
            store        = new ListStore(typeof(string), typeof(string), typeof(object));
            listPK.Model = store;

            TreeViewColumn colName = new TreeViewColumn();

            colName.Title = AddinCatalog.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);

            listPK.Selection.Changed     += new EventHandler(SelectionChanged);
            columnSelecter.ColumnToggled += new EventHandler(ColumnToggled);

            ShowAll();
        }
Exemplo n.º 8
0
		public ViewEditorDialog (ISchemaProvider schemaProvider, bool create, ViewEditorSettings settings)
		{
			if (schemaProvider == null)
				throw new ArgumentNullException ("schemaProvider");
			
			
			this.schemaProvider = schemaProvider;
			this.action = create ? SchemaActions.Create : SchemaActions.Alter;
			
			this.Build();
			
			if (create)
				Title = AddinCatalog.GetString ("Create View");
			else
				Title = AddinCatalog.GetString ("Alter View");
			
			notebook = new Notebook ();

			sqlEditor = new SqlEditorWidget ();
			sqlEditor.TextChanged += new EventHandler (SqlChanged);
			notebook.AppendPage (sqlEditor, new Label (AddinCatalog.GetString ("Definition")));
			
			if (settings.ShowComment) {
				commentEditor = new CommentEditorWidget ();
				notebook.AppendPage (commentEditor, new Label (AddinCatalog.GetString ("Comment")));
			}

			notebook.Page = 0;

			entryName.Text = view.Name;

			vboxContent.PackStart (notebook, true, true, 0);
			vboxContent.ShowAll ();
			SetWarning (null);
		}
Exemplo n.º 9
0
        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();
        }
		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 ();
		}
Exemplo n.º 11
0
        public virtual bool IsSchemaActionSupported(SchemaType type, SchemaActions action)
        {
            SchemaActions supported;

            if (supportedActions.TryGetValue(type, out supported))
            {
                return((supported & action) == action);
            }
            return(false);
        }
Exemplo n.º 12
0
		public IndicesEditorWidget(ISchemaProvider schemaProvider, SchemaActions action)
		{
			if (schemaProvider == null)
				throw new ArgumentNullException ("schemaProvider");
			
			this.schemaProvider = schemaProvider;
			this.action = action;

			this.Build();
		}
Exemplo n.º 13
0
        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();
        }
Exemplo n.º 14
0
 protected virtual void AddSupportedSchemaActions(SchemaType type, SchemaActions actions)
 {
     if (supportedActions.ContainsKey(type))
     {
         supportedActions[type] = supportedActions[type] | actions;
     }
     else
     {
         supportedActions.Add(type, actions);
     }
 }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        public IndicesEditorWidget(ISchemaProvider schemaProvider, SchemaActions action)
        {
            if (schemaProvider == null)
            {
                throw new ArgumentNullException("schemaProvider");
            }

            this.schemaProvider = schemaProvider;
            this.action         = action;

            this.Build();
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
        public ConstraintsEditorWidget(ISchemaProvider schemaProvider, SchemaActions action, ConstraintEditorSettings settings)
        {
            if (schemaProvider == null)
            {
                throw new ArgumentNullException("schemaProvider");
            }

            this.schemaProvider = schemaProvider;
            this.action         = action;

            this.Build();

            notebook = new Notebook();
            Add(notebook);

            if (settings.ShowPrimaryKeyConstraints)
            {
                //not for column constraints, since they are already editable in the column editor
                pkEditor = new PrimaryKeyConstraintEditorWidget(schemaProvider, action);
                pkEditor.ContentChanged    += new EventHandler(OnContentChanged);
                pkEditor.PrimaryKeyChanged += delegate(object sender, EventArgs e) {
                    if (PrimaryKeyChanged != null)
                    {
                        PrimaryKeyChanged(this, new EventArgs());
                    }
                };
                notebook.AppendPage(pkEditor, new Label(AddinCatalog.GetString("Primary Key")));
            }

            if (settings.ShowForeignKeyConstraints)
            {
                fkEditor = new ForeignKeyConstraintEditorWidget(schemaProvider, action, settings.ForeignKeySettings);
                fkEditor.ContentChanged += new EventHandler(OnContentChanged);
                notebook.AppendPage(fkEditor, new Label(AddinCatalog.GetString("Foreign Key")));
            }

            if (settings.ShowCheckConstraints)
            {
                checkEditor = new CheckConstraintEditorWidget(schemaProvider, action, settings.CheckSettings);
                checkEditor.ContentChanged += new EventHandler(OnContentChanged);
                notebook.AppendPage(checkEditor, new Label(AddinCatalog.GetString("Check")));
            }

            if (settings.ShowUniqueConstraints)
            {
                uniqueEditor = new UniqueConstraintEditorWidget(schemaProvider, action);
                uniqueEditor.ContentChanged += new EventHandler(OnContentChanged);
                notebook.AppendPage(uniqueEditor, new Label(AddinCatalog.GetString("Unique")));
            }

            ShowAll();
        }
Exemplo n.º 19
0
		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 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 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);
        }
Exemplo n.º 22
0
        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 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 ();
		}
        public ProcedureEditorDialog(IEditSchemaProvider schemaProvider, bool create, ProcedureEditorSettings settings)
        {
            if (schemaProvider == null)
            {
                throw new ArgumentNullException("schemaProvider");
            }

            this.settings       = settings;
            this.schemaProvider = schemaProvider;
            this.action         = create ? SchemaActions.Create : SchemaActions.Alter;

            this.Build();

            if (create)
            {
                Title = AddinCatalog.GetString("Create Procedure");
            }
            else
            {
                Title = AddinCatalog.GetString("Alter Procedure");
            }

            notebook = new Notebook();

            sqlEditor              = new SqlEditorWidget();
            sqlEditor.TextChanged += new EventHandler(SqlChanged);
            notebook.AppendPage(sqlEditor, new Label(AddinCatalog.GetString("Definition")));

            if (settings.ShowComment)
            {
                commentEditor = new CommentEditorWidget();
                notebook.AppendPage(commentEditor, new Label(AddinCatalog.GetString("Comment")));
            }

            if (!settings.ShowName)
            {
                nameLabel.Visible = false;
                entryName.Visible = false;
            }

            vboxContent.PackStart(notebook, true, true, 0);
            vboxContent.ShowAll();
            SetWarning(null);
        }
Exemplo n.º 25
0
		public ConstraintsEditorWidget (ISchemaProvider schemaProvider, SchemaActions action, ConstraintEditorSettings settings)
		{
			if (schemaProvider == null)
				throw new ArgumentNullException ("schemaProvider");
			
			this.schemaProvider = schemaProvider;
			this.action = action;
	
			this.Build();
			
			notebook = new Notebook ();
			Add (notebook);

			if (settings.ShowPrimaryKeyConstraints) {
				//not for column constraints, since they are already editable in the column editor
				pkEditor = new PrimaryKeyConstraintEditorWidget (schemaProvider, action);
				pkEditor.ContentChanged += new EventHandler (OnContentChanged);
				pkEditor.PrimaryKeyChanged += delegate(object sender, EventArgs e) {
					if (PrimaryKeyChanged != null)
						PrimaryKeyChanged (this, new EventArgs ());
				};
				notebook.AppendPage (pkEditor, new Label (AddinCatalog.GetString ("Primary Key")));
			}
			
			if (settings.ShowForeignKeyConstraints) {
				fkEditor = new ForeignKeyConstraintEditorWidget (schemaProvider, action, settings.ForeignKeySettings);
				fkEditor.ContentChanged += new EventHandler (OnContentChanged);
				notebook.AppendPage (fkEditor, new Label (AddinCatalog.GetString ("Foreign Key")));
			}
			
			if (settings.ShowCheckConstraints) {
				checkEditor = new CheckConstraintEditorWidget (schemaProvider, action, settings.CheckSettings);
				checkEditor.ContentChanged += new EventHandler (OnContentChanged);
				notebook.AppendPage (checkEditor, new Label (AddinCatalog.GetString ("Check")));
			}
			
			if (settings.ShowUniqueConstraints) {
				uniqueEditor = new UniqueConstraintEditorWidget (schemaProvider, action);
				uniqueEditor.ContentChanged += new EventHandler (OnContentChanged);
				notebook.AppendPage (uniqueEditor, new Label (AddinCatalog.GetString ("Unique")));
			}

			ShowAll ();
		}
Exemplo n.º 26
0
        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);
        }
Exemplo n.º 27
0
		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);
		}
Exemplo n.º 28
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);
                    }
                }
            }
        }
Exemplo n.º 29
0
		public TableEditorDialog (IEditSchemaProvider schemaProvider, bool create, TableEditorSettings settings)
		{
			if (schemaProvider == null)
				throw new ArgumentNullException ("schemaProvider");
			
			this.schemaProvider = schemaProvider;
			this.action = create ? SchemaActions.Create : SchemaActions.Alter;
			this.settings = settings;
			
			this.Build();
			
			if (create)
				Title = AddinCatalog.GetString ("Create Table");
			else
				Title = AddinCatalog.GetString ("Alter Table");
			
			notebook = new Notebook ();
			vboxContent.PackStart (notebook, true, true, 0);

			notebook.Sensitive = false;
			ThreadPool.QueueUserWorkItem (new WaitCallback (InitializeThreaded));
			vboxContent.ShowAll ();
		}
Exemplo n.º 30
0
		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 ();
		}
        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();
        }
Exemplo n.º 32
0
		protected override void Read (NodeElement elem)
		{
			base.Read (elem);
			
			actions = (SchemaActions)Enum.Parse (typeof (SchemaActions), flags);
		}
		protected virtual void AddSupportedSchemaActions (SchemaType type, SchemaActions actions)
		{
			if (supportedActions.ContainsKey (type))
				supportedActions[type] = supportedActions[type] | actions;
			else
				supportedActions.Add (type, actions);
		}
		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 ();
		}
Exemplo n.º 35
0
        public ColumnsEditorWidget(ISchemaProvider schemaProvider, SchemaActions action, ColumnEditorSettings settings)
        {
            if (schemaProvider == null)
            {
                throw new ArgumentNullException("schemaProvider");
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            this.schemaProvider = schemaProvider;
            this.action         = action;
            this.settings       = settings;

            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       = AddinCatalog.GetString("PK");
            colName.Title     = AddinCatalog.GetString("Name");
            colType.Title     = AddinCatalog.GetString("Type");
            colLength.Title   = AddinCatalog.GetString("Length");
            colNullable.Title = AddinCatalog.GetString("Nullable");
            colComment.Title  = AddinCatalog.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;
            storeTypes.SetSortColumnId(0, SortType.Ascending);
            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);

            if (settings.ShowPrimaryKeyColumn)
            {
                treeColumns.AppendColumn(colPK);
            }
            if (settings.ShowNameColumn)
            {
                treeColumns.AppendColumn(colName);
            }
            if (settings.ShowTypeColumn)
            {
                treeColumns.AppendColumn(colType);
            }
            if (settings.ShowLengthColumn)
            {
                treeColumns.AppendColumn(colLength);
            }
            if (settings.ShowNullableColumn)
            {
                treeColumns.AppendColumn(colNullable);
            }
            if (settings.ShowCommentColumn)
            {
                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    = settings.ShowAddButton;
                buttonRemove.Sensitive = settings.ShowRemoveButton;
                buttonUp.Sensitive     = settings.AllowReorder;
            }

            ShowAll();
        }
        //TODO: difference between columns and reference columns + combo events
        public ForeignKeyConstraintEditorWidget(ISchemaProvider schemaProvider, SchemaActions action, ForeignKeyConstraintEditorSettings settings)
        {
            if (schemaProvider == null)
            {
                throw new ArgumentNullException("schemaProvider");
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            this.schemaProvider = schemaProvider;
            this.action         = action;
            this.settings       = settings;

            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), typeof(TableSchema));

            if (settings.SupportsCascade)
            {
                storeActions.AppendValues("Cascade", (int)ForeignKeyAction.Cascade);
            }
            if (settings.SupportsRestrict)
            {
                storeActions.AppendValues("Restrict", (int)ForeignKeyAction.Restrict);
            }
            if (settings.SupportsNoAction)
            {
                storeActions.AppendValues("No Action", (int)ForeignKeyAction.NoAction);
            }
            if (settings.SupportsSetNull)
            {
                storeActions.AppendValues("Set Null", (int)ForeignKeyAction.SetNull);
            }
            if (settings.SupportsSetDefault)
            {
                storeActions.AppendValues("Set Default", (int)ForeignKeyAction.SetDefault);
            }

            TreeViewColumn colName               = new TreeViewColumn();
            TreeViewColumn colRefTable           = new TreeViewColumn();
            TreeViewColumn colIsColumnConstraint = new TreeViewColumn();
            TreeViewColumn colDeleteAction       = new TreeViewColumn();
            TreeViewColumn colUpdateAction       = new TreeViewColumn();

            colName.Title               = AddinCatalog.GetString("Name");
            colRefTable.Title           = AddinCatalog.GetString("Reference Table");
            colIsColumnConstraint.Title = AddinCatalog.GetString("Column Constraint");
            colDeleteAction.Title       = AddinCatalog.GetString("Delete Action");
            colUpdateAction.Title       = AddinCatalog.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);

            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);

            colIsColumnConstraint.Visible = false;
            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();
        }
Exemplo n.º 37
0
		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 ();
		}
Exemplo n.º 38
0
        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();
        }
Exemplo n.º 39
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);
					}
				}
			}
		}
Exemplo n.º 40
0
		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;
		}
Exemplo n.º 41
0
		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);
		}
		//TODO: difference between columns and reference columns + combo events
		public ForeignKeyConstraintEditorWidget (ISchemaProvider schemaProvider, SchemaActions action, ForeignKeyConstraintEditorSettings settings)
		{
			if (schemaProvider == null)
				throw new ArgumentNullException ("schemaProvider");
			if (settings == null)
				throw new ArgumentNullException ("settings");
			
			this.schemaProvider = schemaProvider;
			this.action = action;
			this.settings = settings;

			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), typeof(TableSchema));
			
			if (settings.SupportsCascade)
				storeActions.AppendValues ("Cascade", (int)ForeignKeyAction.Cascade);
			if (settings.SupportsRestrict)
				storeActions.AppendValues ("Restrict", (int)ForeignKeyAction.Restrict);
			if (settings.SupportsNoAction)
				storeActions.AppendValues ("No Action", (int)ForeignKeyAction.NoAction);
			if (settings.SupportsSetNull)
				storeActions.AppendValues ("Set Null", (int)ForeignKeyAction.SetNull);
			if (settings.SupportsSetDefault)
				storeActions.AppendValues ("Set Default", (int)ForeignKeyAction.SetDefault);

			TreeViewColumn colName = new TreeViewColumn ();
			TreeViewColumn colRefTable = new TreeViewColumn ();
			TreeViewColumn colIsColumnConstraint = new TreeViewColumn ();
			TreeViewColumn colDeleteAction = new TreeViewColumn ();
			TreeViewColumn colUpdateAction = new TreeViewColumn ();
			
			colName.Title = AddinCatalog.GetString ("Name");
			colRefTable.Title = AddinCatalog.GetString ("Reference Table");
			colIsColumnConstraint.Title = AddinCatalog.GetString ("Column Constraint");
			colDeleteAction.Title = AddinCatalog.GetString ("Delete Action");
			colUpdateAction.Title = AddinCatalog.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);
			
			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);
			
			colIsColumnConstraint.Visible = false;
			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 ();
		}
		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 = AddinCatalog.GetString ("Name");
			colType.Title = AddinCatalog.GetString ("Type");
			colEvent.Title = AddinCatalog.GetString ("Event");
			colFireType.Title = AddinCatalog.GetString ("Each Row");
			colPosition.Title = AddinCatalog.GetString ("Position");
			colActive.Title = AddinCatalog.GetString ("Active");
			colComment.Title = AddinCatalog.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 virtual bool IsSchemaActionSupported (SchemaType type, SchemaActions action)
		{
			SchemaActions supported;
			if (supportedActions.TryGetValue (type, out supported))
				return (supported & action) == action;
			return false;
		}
		//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 ();
		}
Exemplo n.º 46
0
		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;
		}
Exemplo n.º 47
0
        public bool IsActionSupported(string category, SchemaActions action)
        {
            SchemaActions actions = GetSupportedActions(category);

            return((actions & action) == action);
        }
Exemplo n.º 48
0
        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();
        }
Exemplo n.º 49
0
        protected override void Read(NodeElement elem)
        {
            base.Read(elem);

            actions = (SchemaActions)Enum.Parse(typeof(SchemaActions), flags);
        }
Exemplo n.º 50
0
        public CheckConstraintEditorWidget(ISchemaProvider schemaProvider, SchemaActions action, CheckConstraintEditorSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            if (schemaProvider == null)
            {
                throw new ArgumentNullException("schemaProvider");
            }

            this.schemaProvider = schemaProvider;
            this.settings       = settings;
            this.action         = action;

            this.Build();

            store = new ListStore(typeof(string), typeof(string), typeof(bool), typeof(string), typeof(object));

            listCheck.Model = store;

            TreeViewColumn colName               = new TreeViewColumn();
            TreeViewColumn colColumn             = new TreeViewColumn();
            TreeViewColumn colIsColumnConstraint = new TreeViewColumn();

            colName.Title               = AddinCatalog.GetString("Name");
            colColumn.Title             = AddinCatalog.GetString("Column");
            colIsColumnConstraint.Title = AddinCatalog.GetString("Column Constraint");

            colColumn.MinWidth = 120;             //request a bigger width

            CellRendererText nameRenderer = new CellRendererText();

            columnRenderer = new CellRendererCombo();
            CellRendererToggle isColumnConstraintRenderer = new CellRendererToggle();

            nameRenderer.Editable = true;
            nameRenderer.Edited  += new EditedHandler(NameEdited);

            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);

            listCheck.AppendColumn(colName);
            if (settings.SupportsColumnConstraints)
            {
                listCheck.AppendColumn(colColumn);
            }
            if (settings.SupportsColumnConstraints && settings.SupportsTableConstraints)
            {
                listCheck.AppendColumn(colIsColumnConstraint);
            }

            listCheck.Selection.Changed += new EventHandler(OnSelectionChanged);
            sqlEditor.TextChanged       += new EventHandler(SourceChanged);

            ShowAll();
        }
Exemplo n.º 51
0
        //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();
        }
Exemplo n.º 52
0
		public bool IsActionSupported (string category, SchemaActions action)
		{
			SchemaActions actions = GetSupportedActions (category);
			return (actions & action) == action;
		}
Exemplo n.º 53
0
        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);
        }
Exemplo n.º 54
0
        private static async Task StartFetching()
        {
            Console.WriteLine("\nSelected datasets models - quantity:");
            datasetsGroups.ForEach(d =>
                                   Console.WriteLine(" -[DB Model] " + d.DatabaseCode + " - " + d.Datasets.Count)
                                   );
            Console.WriteLine();

            Console.WriteLine("\nDetecting newest data available:");
            foreach (QuandlDatasetGroup datasetGroup in datasetsGroups)
            {
                List <Tuple <DateTime, string> > datasetNewestDateList = PostgresHelpers.QuandlDatasetActions.GetNewestImportedData(datasetGroup);

                // Item1 = Newest date of data
                // Item2 = Dataset code
                foreach (var tuple in datasetNewestDateList)
                {
                    // Will only add those who dataset is imported
                    QuandlDataset dataset = datasetGroup.Datasets.Find(d => d.DatasetCode == tuple.Item2);
                    if (dataset != null)
                    {
                        dataset.LastFetch = tuple.Item1;
                    }
                }
            }

            int count = 0;

            foreach (QuandlDatasetGroup datasetGroup in datasetsGroups)
            {
                // Update groups to fetched count
                count++;

                // Identify current group
                Utils.ConsoleInformer.InformSimple("Group model: [" + datasetGroup.DatabaseCode + "]. Group:" + count + "/" + datasetsGroups.Count);

                // Make datasets model tables
                Console.WriteLine("Creating unique table model for datasets:");
                SchemaActions.CreateQuandlDatasetDataTable(datasetGroup);
                Console.WriteLine();

                // Request all datasets from group
                await DownloadDatasetsDataAsync(datasetGroup, datasetGroup.Datasets.Count);
            }

            if (failedToFetch.Any())
            {
                datasetsGroups.Clear();
                datasetsGroups.AddRange(failedToFetch);

                Console.WriteLine("\n######################################################################");
                Console.WriteLine("\nFetching failed datasets data");
                Console.WriteLine("Waiting 11 minutes (quandl limitation) before fetching remaning ones");

                for (int totalSeconds = 11 * 60; totalSeconds >= 0; totalSeconds--)
                {
                    int    seconds = totalSeconds % 60;
                    int    minutes = totalSeconds / 60;
                    string time    = minutes + ":" + seconds;

                    Console.CursorLeft = 0;
                    Console.Write("{0} ", time);    // Add space to make sure to override previous contents
                    System.Threading.Thread.Sleep(1000);
                }

                failedToFetch.Clear();
                await StartFetching();
            }

            // Make datasets model tables
            //PostgresHelpers.QuandlDatasetActions.InsertQuandlDatasetsData(datasetsDataGroups);
        }