Exemplo n.º 1
0
        public void Initialize(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");
            }

            this.table       = table;
            this.columns     = columns;
            this.constraints = constraints;

            columnSelecter.Initialize(columns);

            foreach (UniqueConstraintSchema uni in constraints.GetConstraints(ConstraintType.Unique))
            {
                AddConstraint(uni);
            }

            //TODO: also col constraints
        }
Exemplo n.º 2
0
        public void Initialize(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");
            }

            this.table       = table;
            this.columns     = columns;
            this.constraints = constraints;

            foreach (CheckConstraintSchema check in constraints.GetConstraints(ConstraintType.Check))
            {
                AddConstraint(check);
            }
            storeColumns         = new SortedColumnListStore(columns);
            columnRenderer.Model = storeColumns.Store;

            //TODO: also col constraints
        }
 public virtual void RefreshConstraints()
 {
     store.Clear();
     foreach (PrimaryKeyConstraintSchema pk in constraints.GetConstraints(ConstraintType.PrimaryKey))
     {
         AddConstraint(pk);
     }
 }
Exemplo n.º 4
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();
        }
		public void Initialize (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");
			
			this.table = table;
			this.columns = columns;
			this.constraints = constraints;
			
			columnSelecter.Initialize (columns);
			
			foreach (UniqueConstraintSchema uni in constraints.GetConstraints (ConstraintType.Unique))
				AddConstraint (uni);
			
			//TODO: also col constraints
		}
        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.º 7
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();
        }
		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 void Initialize (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");

			this.table = table;
			this.columns = columns;
			this.constraints = constraints;
			
			foreach (CheckConstraintSchema check in constraints.GetConstraints (ConstraintType.Check))
				AddConstraint (check);
			storeColumns = new SortedColumnListStore (columns);
			columnRenderer.Model = storeColumns.Store;
			
			//TODO: also col constraints
		}
		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 ();
		}
		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 ();
		}