Ejemplo n.º 1
0
		public TableEditorSettings ()
		{
			constraintSettings = new ConstraintEditorSettings ();
			columnSettings = new ColumnEditorSettings ();
		}
		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 ();
		}
        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();
        }
Ejemplo n.º 4
0
 public TableEditorSettings()
 {
     constraintSettings = new ConstraintEditorSettings();
     columnSettings     = new ColumnEditorSettings();
 }