protected virtual void RemoveClicked(object sender, EventArgs e) { TreeIter iter; if (listCheck.Selection.GetSelected(out iter)) { CheckConstraintSchema check = store.GetValue(iter, colObjIndex) as CheckConstraintSchema; if (MessageService.Confirm( AddinCatalog.GetString("Are you sure you want to remove constraint '{0}'?", check.Name), AlertButton.Remove )) { store.Remove(ref iter); constraints.Remove(check); EmitContentChanged(); } } }
protected virtual void RemoveClicked(object sender, EventArgs e) { TreeIter iter; if (listUnique.Selection.GetSelected(out iter)) { UniqueConstraintSchema uni = store.GetValue(iter, colObjIndex) as UniqueConstraintSchema; if (Services.MessageService.AskQuestion( GettextCatalog.GetString("Are you sure you want to remove constraint '{0}'?", uni.Name), GettextCatalog.GetString("Remove Constraint") )) { store.Remove(ref iter); constraints.Remove(uni); EmitContentChanged(); } } }
protected virtual void RemoveClicked(object sender, System.EventArgs e) { TreeIter iter; if (listPK.Selection.GetSelected(out iter)) { PrimaryKeyConstraintSchema pk = store.GetValue(iter, colObjIndex) as PrimaryKeyConstraintSchema; if (Services.MessageService.AskQuestion( GettextCatalog.GetString("Are you sure you want to remove constraint '{0}'?", pk.Name), GettextCatalog.GetString("Remove Constraint") )) { store.Remove(ref iter); constraints.Remove(pk); EmitContentChanged(); } } }
private void PkToggled(object sender, ToggledArgs args) { TreeIter iter; if (storeColumns.GetIterFromString(out iter, args.Path)) { bool val = (bool)storeColumns.GetValue(iter, colPKIndex); storeColumns.SetValue(iter, colPKIndex, !val); if (val) { // Remove Constraint ColumnSchema column = storeColumns.GetValue(iter, colObjIndex) as ColumnSchema; ConstraintSchema delConstraint = null; foreach (ConstraintSchema c in constraints) { if (c is PrimaryKeyConstraintSchema) { foreach (ColumnSchema col in c.Columns) { if (col.Name == column.Name) { c.Columns.Remove(col); delConstraint = c; break; } } } } // If PK doesn't have any columns, delete it. if (delConstraint != null) { if (delConstraint.Columns.Count < 1) { constraints.Remove(delConstraint); } } } else { // Add Constraint ColumnSchema column = storeColumns.GetValue(iter, colObjIndex) as ColumnSchema; // Add the column for an existing PK foreach (ConstraintSchema c in constraints) { if (c is PrimaryKeyConstraintSchema) { c.Columns.Add(column); // Fire the Primary Key Changed Event to tell the other widget that "Primary Key Constraint" // are changed in the Column Editor. OnPrimaryKeyChanged(this, new EventArgs()); EmitContentChanged(); return; } } PrimaryKeyConstraintSchema pk = schemaProvider.CreatePrimaryKeyConstraintSchema(string.Concat( table.Name, "_", AddinCatalog.GetString("pk_new") )); pk.Columns.Add(column); constraints.Add(pk); } OnPrimaryKeyChanged(this, new EventArgs()); EmitContentChanged(); } }