bool Save(bool prompt) { UserObject uo2; if (!IsValidCalcField()) { return(false); } if (!GetCalcFieldForm()) { return(false); } if (prompt) { uo2 = UserObjectSaveDialog.Show("Save Calculated Field Definition", UoIn); if (uo2 == null) { return(false); } } else { uo2 = UoIn.Clone(); } if (!UserObjectUtil.UserHasWriteAccess(uo2)) { // is the user authorized to save this? MessageBoxMx.ShowError("You are not authorized to save this calculated field"); return(false); } SessionManager.DisplayStatusMessage("Saving calculated field..."); string content = CalcField.Serialize(); uo2.Content = content; //need the name of the folder to which the object will be saved MetaTreeNode targetFolder = UserObjectTree.GetValidUserObjectTypeFolder(uo2); if (targetFolder == null) { MessageBoxMx.ShowError("Failed to save your calculated field."); return(false); } UserObjectDao.Write(uo2); string tName = "CALCFIELD_" + uo2.Id.ToString(); QbUtil.UpdateMetaTableCollection(tName); MainMenuControl.UpdateMruList(tName); string title = "Edit Calculated Field - " + uo2.Name; Text = title; UoIn = uo2.Clone(); // now becomes input object SessionManager.DisplayStatusMessage(""); return(true); }
void Setup(UserObject uo) { Text = "Permissions for " + uo.Name; Uo = uo; if (UserObjectUtil.UserHasWriteAccess(uo)) { Editable = true; PermissionsList.Editable = true; MakePublic.Enabled = MakePrivate.Enabled = AdvancedButton.Enabled = true; } else { Editable = false; PermissionsList.Editable = false; MakePublic.Enabled = MakePrivate.Enabled = AdvancedButton.Enabled = false; } AccessControlList acl = AccessControlList.Deserialize(uo); PermissionsList.Setup(acl); return; }
/// <summary> /// Change owner /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ChangeOwnerMenuItem_Click(object sender, EventArgs e) { { List <string> users = SecurityUtil.GetAllUsers(); string prompt = "Enter the user name of the person to transfer ownership of " + Lex.AddDoubleQuotes(Uo.Name) + " to:"; string newOwner = InputBoxMx.Show(prompt, "Change Owner", "", users, -1, -1); if (Lex.IsNullOrEmpty(newOwner)) { return; } string newUserName = SecurityUtil.GetInternalUserName(newOwner); if (Lex.IsNullOrEmpty(newUserName)) { return; } string result = UserObjectUtil.ChangeOwner(Uo.Id, newUserName); if (!Lex.IsNullOrEmpty(result)) { MessageBoxMx.Show(result); DialogResult = DialogResult.Cancel; // close the dialog } return; } }
/// <summary> /// See if current user can modify supplied annotation table or calc field /// </summary> /// <param name="mt"></param> /// <returns></returns> public static bool CanModifyTable( MetaTable mt) { if (mt.MetaBrokerType == MetaBrokerType.Unknown) { return(true); // Allow if no broker type (i.e. Transient Conditional Formatting control, etc) } else if (mt.MetaBrokerType == MetaBrokerType.Annotation || mt.MetaBrokerType == MetaBrokerType.CalcField) { if (mt.Code == null || mt.Code == "" || mt.Code == "0") { return(true); // assume ok if new object with no code assigned } return(UserObjectUtil.UserHasWriteAccess(SS.I.UserName, Int32.Parse(mt.Code))); // the code for the table is the object id } else if (mt.IsUserDatabaseStructureTable) { if (mt.Code == null || mt.Code == "" || mt.Code == "0") { return(true); // assume ok if new object with no code assigned } long databaseId = Int64.Parse(mt.Code); UserCmpndDbDao udbs = new UserCmpndDbDao(); return(udbs.CanModifyDatabase(databaseId, SS.I.UserName)); } else { return(false); } }
/// <summary> /// See if the named list exists /// </summary> /// <param name="name"></param> /// <returns></returns> public static bool Exists( string name) { UserObject uo = UserObjectUtil.ParseInternalUserObjectName(name); uo.Type = UserObjectType.CnList; uo = UserObjectDao.ReadHeader(uo); return(uo != null); }
/// <summary> /// Save the SpotfireLink UserObject /// </summary> /// <param name="prompt"></param> /// <returns></returns> bool Save(bool prompt) { UserObject uo2; if (!IsValidSpotfireLink()) { return(false); } if (!GetSpotfireLinkForm()) { return(false); } if (prompt) { uo2 = UserObjectSaveDialog.Show("Save Spotfire link Definition", UoIn); if (uo2 == null) { return(false); } } else { uo2 = UoIn.Clone(); } uo2.Content = SpotfireViewProps.Serialize(); if (!UserObjectUtil.UserHasWriteAccess(uo2)) { // is the user authorized to save this? MessageBoxMx.ShowError("You are not authorized to save this Spotfire link"); return(false); } SessionManager.DisplayStatusMessage("Saving Spotfire link..."); //need the name of the folder to which the object will be saved MetaTreeNode targetFolder = UserObjectTree.GetValidUserObjectTypeFolder(uo2); if (targetFolder == null) { MessageBoxMx.ShowError("Failed to save your Spotfire link."); return(false); } UserObjectDao.Write(uo2); MainMenuControl.UpdateMruList(uo2.InternalName); string title = "Edit Spotfire Link - " + uo2.Name; Text = title; UoIn = uo2.Clone(); // now becomes input object SessionManager.DisplayStatusMessage(""); return(true); }
/// <summary> /// Set Enable for a Paste ToolStripMenuItem based on whether there is a UserObject in the clipboard /// </summary> /// <param name="mi"></param> void SetPasteEnable(ToolStripMenuItem mi) { bool enable = false; try { string txt = Clipboard.GetText(); //if (UserObject.Deserialize(txt) != null) enable = true; UserObject[] userobjects = UserObjectUtil.Deserialize(txt); if (userobjects != null) { enable = true; } } catch (Exception ex) { } mi.Enabled = enable; return; }
/// <summary> /// See if the current user can modify the supplied object /// </summary> /// <param name="objectId"></param> /// <returns></returns> public static bool UserHasWriteAccess( string userName, int objectId) { if (objectId <= 0) { return(true); // new unsaved object } if (objectId == LastUserHasWriteAccessId) { return(LastUserHasWriteAccessResult); } UserObject uo = UserObjectDao.ReadHeader(objectId); LastUserHasWriteAccessId = objectId; LastUserHasWriteAccessResult = UserObjectUtil.UserHasWriteAccess(uo); return(LastUserHasWriteAccessResult); }
/// <summary> /// Read a compound id list given an internal list name (e.g. FOLDER_123.name or LIST_1234) /// </summary> /// <param name="name"></param> /// <param name="mt"></param> /// <returns></returns> public static CidList Read( string internalName, MetaTable mt, bool allowLocalRead) { UserObject uo, uo2; string fileName, cn; int i1; uo = UserObjectUtil.ParseInternalUserObjectName(internalName, UserObjectType.CnList); if (uo == null) { return(null); } if (allowLocalRead && UserObject.IsCurrentObjectInternalName(internalName)) // get from the current query { return(ReadCurrentListLocal()); } uo2 = UserObjectDao.Read(uo); // get from the server side if (uo2 == null) { MessageBoxMx.ShowError( "Unable to find list: " + internalName + "\r\n\r\n" + CommandExec.GetUserObjectReadAccessErrorMessage(uo.Id, "list")); return(null); } CidList cnList = CidList.Deserialize(uo2, mt); if (UserObject.IsCurrentObjectInternalName(internalName)) // if current list store keys with query { SessionManager.CurrentResultKeys = cnList.ToStringList(); } return(cnList); }
/// <summary> /// Create an annotation table from a DataTable /// </summary> /// <param name="fullyQualifiedName">Fully qualified name to assign to table</param> /// <param name="dataTable">DataTable containing table definition & data</param> /// <param name="showProgress">Display dialog box showing progress of creation</param> /// <returns>Internal name assigned to annotation table (ANNOTATION_12345)</returns> public static MetaTable CreateAnnotationTable( string fullyQualifiedName, DataTable dataTable, bool showProgress) { List <AnnotationVo> voList = new List <AnnotationVo>(); AnnotationVo avo; if (dataTable == null) { DebugMx.ArgException("DataTable is null"); } if (dataTable.Columns.Count == 0) { DebugMx.ArgException("No DataColumns are defined"); } if (dataTable.Columns[0].DataType != typeof(CompoundId)) { DebugMx.ArgException("The first column must be of type CompoundId"); } if (showProgress) { Progress.Show("Creating annotation table..."); } AnnotationDao aDao = new AnnotationDao(); UserObject auo = UserObjectUtil.ParseInternalUserObjectName(fullyQualifiedName); auo.Type = UserObjectType.Annotation; UserObjectTree.GetValidUserObjectTypeFolder(auo); UserObject auo2 = UserObjectDao.Read(auo); // see if there already MetaTable oldMt = null; if (auo2 == null) // get new identifier { auo.Id = UserObjectDao.GetNextId(); // id to store table under } else // reuse identifier { auo.Id = auo2.Id; // copy it over aDao.DeleteTable(auo.Id); // delete any existing data string oldMtName = "ANNOTATION_" + auo2.Id; oldMt = MetaTableCollection.Get(oldMtName); } MetaTable mt = new MetaTable(); mt.MetaBrokerType = MetaBrokerType.Annotation; mt.Name = "ANNOTATION_" + auo.Id; // name table by uo mt.Label = auo.Name; mt.Code = auo.Id.ToString(); // code for the metatable int mtCode = auo.Id; if (dataTable.ExtendedProperties.ContainsKey("ParentTableName")) { mt.Parent = MetaTableCollection.Get((string)dataTable.ExtendedProperties["ParentTableName"]); } foreach (DataColumn dc in dataTable.Columns) { MetaColumn mc = new MetaColumn(); mc.MetaTable = mt; mc.Name = dc.ColumnName; MetaColumn oldMc = null; if (oldMt != null) { oldMc = oldMt.GetMetaColumnByName(mc.Name); // see if column name exists } if (oldMc != null && oldMc.ResultCode != "") // use any existing code { mc.ResultCode = oldMc.ResultCode; } else { mc.ResultCode = aDao.GetNextIdLong().ToString(); } if (dc.Caption != null) { mc.Label = dc.Caption; } else { mc.Label = mc.Name; } if (dc.DataType == typeof(CompoundId)) { mc.DataType = MetaColumnType.CompoundId; if (dc.ExtendedProperties.ContainsKey("StorageType") && dc.ExtendedProperties["StorageType"] is MetaColumnType && ((MetaColumnType)dc.ExtendedProperties["StorageType"]) == MetaColumnType.String) { mc.ColumnMap = "EXT_CMPND_ID_TXT"; // text column } else { mc.ColumnMap = "EXT_CMPND_ID_NBR"; // numeric column otherwise } } else if (dc.DataType == typeof(int) || dc.DataType == typeof(Int16) || dc.DataType == typeof(Int32)) { mc.DataType = MetaColumnType.Integer; } else if (dc.DataType == typeof(float) || dc.DataType == typeof(double)) { mc.DataType = MetaColumnType.Number; } else if (dc.DataType == typeof(QualifiedNumber)) { mc.DataType = MetaColumnType.QualifiedNo; } else if (dc.DataType == typeof(string)) { mc.DataType = MetaColumnType.String; } else if (dc.DataType == typeof(DateTime)) { mc.DataType = MetaColumnType.Date; } else if (dc.DataType == typeof(MoleculeMx)) { mc.DataType = MetaColumnType.Structure; } else { throw new Exception("Invalid data type " + dc.DataType.ToString()); } if (dc.ExtendedProperties.ContainsKey("DisplayLevel")) { mc.InitialSelection = (ColumnSelectionEnum)dc.ExtendedProperties["DisplayLevel"]; } if (dc.ExtendedProperties.ContainsKey("DisplayWidth")) { mc.Width = (float)dc.ExtendedProperties["DisplayWidth"]; } if (dc.ExtendedProperties.ContainsKey("DisplayFormat")) { mc.Format = (ColumnFormatEnum)dc.ExtendedProperties["DisplayFormat"]; } if (dc.ExtendedProperties.ContainsKey("Decimals")) { mc.Decimals = (int)dc.ExtendedProperties["Decimals"]; } mt.MetaColumns.Add(mc); } ToolHelper.CreateAnnotationTable(mt, auo); aDao.BeginTransaction(); // insert all data in single transaction if (showProgress) { Progress.Show("Writing data to annotation table..."); } int t1 = TimeOfDay.Milliseconds(); int writeCount = 0; foreach (DataRow dr in dataTable.Rows) { if (dr.IsNull(0)) { continue; // shouldn't happen } string key = dr[0].ToString(); key = CompoundId.NormalizeForDatabase(key, mt.Root); long rslt_grp_id = aDao.GetNextIdLong(); for (int ci = 1; ci < dataTable.Columns.Count; ci++) // do columns after key { if (dr.IsNull(ci)) { continue; } DataColumn dc = dataTable.Columns[ci]; MetaColumn mc = mt.MetaColumns[ci]; int mcCode = Int32.Parse(mc.ResultCode); avo = new AnnotationVo(); avo.rslt_grp_id = rslt_grp_id; // keep row together if (dc.DataType == typeof(CompoundId)) // shouldn't happen since key processed already { avo.rslt_val_txt = dr[ci].ToString(); } else if (dc.DataType == typeof(int) || dc.DataType == typeof(Int16) || dc.DataType == typeof(Int32) || dc.DataType == typeof(float) || dc.DataType == typeof(double)) { avo.rslt_val_nbr = (double)dr[ci]; } else if (dc.DataType == typeof(QualifiedNumber)) { QualifiedNumber qn = (QualifiedNumber)dr[ci]; avo.rslt_val_nbr = qn.NumberValue; avo.rslt_val_prfx_txt = qn.Qualifier; avo.rslt_val_txt = qn.TextValue; avo.dc_lnk = qn.Hyperlink; } else if (dc.DataType == typeof(string)) { avo.rslt_val_txt = dr[ci].ToString(); } else if (dc.DataType == typeof(DateTime)) { avo.rslt_val_dt = (DateTime)dr[ci]; } else if (dc.DataType == typeof(MoleculeMx)) { avo.rslt_val_txt = dr[ci].ToString(); } AddAnnotationVoToList(avo, key, mtCode, mcCode, voList); } writeCount++; if (Progress.CancelRequested) // check for cancel { aDao.Commit(); aDao.Insert(voList); voList.Clear(); aDao.Commit(); aDao.Dispose(); if (showProgress) { Progress.Hide(); } MessageBoxMx.ShowError("Writing of annotation table cancelled."); return(null); } int t2 = TimeOfDay.Milliseconds(); if (showProgress && t2 - t1 >= 1000) { t1 = t2; Progress.Show("Writing data to annotation table " + writeCount.ToString() + " of " + dataTable.Rows.Count.ToString() + " ..."); aDao.Insert(voList); voList.Clear(); aDao.Commit(); } } aDao.Insert(voList); voList.Clear(); aDao.Commit(); aDao.Dispose(); if (showProgress) { Progress.Hide(); } return(mt); // return metatable name }
/// <summary> /// Right-click commands on objects in a tree /// </summary> /// <param name="command">The command to process</param> /// <param name="mtn">MetaTreeNode</param> /// <param name="uo">Any associated user object</param> /// <param name="ctc">ContentsTreeControl</param> /// <returns></returns> public static bool ProcessCommonRightClickObjectMenuCommands( string command, MetaTreeNode mtn, UserObject[] uoArray, ContentsTreeControl ctc) { UserObject uo2; string txt; UserObject uo = null; if (uoArray != null && uoArray.Length == 1) { uo = uoArray[0]; } //if (mtn == null) //{ // MessageBoxMx.ShowError("Operation is not allowed for this Database Contents node."); // return true; //} if (Lex.Eq(command, "Cut")) { CopyCutDelete(command, uoArray, ctc, true, true); } else if (Lex.Eq(command, "Copy")) { CopyCutDelete(command, uoArray, ctc, true, false); } else if (Lex.Eq(command, "Paste")) { try { txt = Clipboard.GetText(); //uo2 = UserObject.Deserialize(txt); uoArray = Deserialize(txt); if (uoArray == null) { throw new Exception("Not a UserObject"); } //if (uo2 == null) throw new Exception("Not a UserObject"); } catch (Exception ex) { MessageBoxMx.ShowError("The clipboard does not contain a recognized user objects"); return(true); } foreach (var userObject in uoArray) { Progress.Show("Pasting " + userObject.Name + "...", UmlautMobius.String, false); Permissions.UpdateAclForNewOwner(userObject, userObject.Owner, SS.I.UserName); // fixup the ACL for the new owner userObject.Owner = SS.I.UserName; userObject.ParentFolder = mtn.Name; mtn = UserObjectTree.GetValidUserObjectTypeFolder(userObject); for (int ci = 0; ; ci++) // find a name that's not used { UserObject uo3 = UserObjectDao.ReadHeader(userObject); if (uo3 == null) { break; } if (ci == 0) { userObject.Name = "Copy of " + userObject.Name; } else if (ci == 1) { userObject.Name = Lex.Replace(userObject.Name, "Copy of ", "Copy (2) of "); } else { userObject.Name = Lex.Replace(userObject.Name, "Copy (" + ci + ") of ", "Copy (" + (ci + 1) + ") of "); } } UserObject userObjectFinal = null; if (UserObjectDao.ReadHeader(userObject.Id) != null) // create a deep clone if orignal object exists { userObjectFinal = DeepClone(userObject); } if (userObjectFinal == null) { userObjectFinal = userObject; } UserObjectDao.Write(userObjectFinal, userObjectFinal.Id); // write using the current id Progress.Hide(); } //if (ctc != null) // need to update form directly? // UserObjectTree.RefreshSubtreeInTreeControl(uo2, ctc); } else if (Lex.Eq(command, "Delete")) { CopyCutDelete(command, uoArray, ctc, false, true); } else if (Lex.Eq(command, "Rename")) { if (!UserHasWriteAccess(uo)) { MessageBoxMx.ShowError("You are not authorized to rename " + uo.Name); return(true); } string newName = InputBoxMx.Show("Enter the new name for " + uo.Name, "Rename", uo.Name); if (newName == null || newName == "" || newName == uo.Name) { return(true); } if (!IsValidUserObjectName(newName)) { MessageBoxMx.ShowError("The name " + newName + " is not valid."); return(true); } uo2 = uo.Clone(); uo2.Name = newName; uo2.Id = 0; // clear Id so not looked up by id if (!Lex.Eq(newName, uo.Name) && UserObjectDao.ReadHeader(uo2) != null) { MessageBoxMx.ShowError(newName + " already exists."); return(true); } uo2.Id = uo.Id; UserObjectDao.UpdateHeader(uo2); if (ctc != null) { UserObjectTree.UpdateObjectInTreeControl(uo, uo2, ctc); } } else if (Lex.Eq(command, "MakePublic") || Lex.Eq(command, "MakePrivate")) { UserObjectAccess newAccess; MetaTreeNode objFolder; if (!UserHasWriteAccess(uo)) { MessageBoxMx.ShowError("You are not authorized to make " + uo.Name + ((Lex.Eq(command, "MakePublic")) ? " public" : " private")); return(true); } if (Lex.Eq(command, "MakePublic")) { if (uo.ParentFolder == "DEFAULT_FOLDER") { MessageBoxMx.ShowError("Items in the Default Folder cannot be made public"); return(true); } else { //check the folder id parentage to ensure that the current folder isn't a subfolder of the default folder if (UserObjectTree.FolderNodes.ContainsKey(uo.ParentFolder)) { objFolder = UserObjectTree.FolderNodes[uo.ParentFolder]; while (objFolder != null) { if (objFolder.Target == "DEFAULT_FOLDER") { MessageBoxMx.ShowError("Items in the Default Folder cannot be made public"); return(true); } objFolder = objFolder.Parent; } } else { throw new Exception("Failed to recognize the folder that this object is in!"); } } newAccess = UserObjectAccess.Public; } else { //user folders cannot be made private if they contain public children if (uo.Type == UserObjectType.Folder) { objFolder = UserObjectTree.BuildNode(uo); if (UserObjectTree.FolderNodes.ContainsKey(objFolder.Target)) { objFolder = UserObjectTree.FolderNodes[objFolder.Target]; for (int i = 0; i < objFolder.Nodes.Count; i++) { MetaTreeNode currentChild = (MetaTreeNode)objFolder.Nodes[i]; } } } newAccess = UserObjectAccess.Private; } uo2 = UserObjectDao.Read(uo); if (uo2 == null) { return(true); } if (uo2.AccessLevel == newAccess) { return(true); // no change } uo2.AccessLevel = newAccess; UserObjectDao.UpdateHeader(uo2); if (ctc != null) // need to update form directly? { UserObjectTree.RefreshSubtreeInTreeControl(uo2, ctc); } return(true); } else if (Lex.Eq(command, "ChangeOwner")) { string newOwner = InputBoxMx.Show("Enter the user name of the person to transfer ownership of " + Lex.AddDoubleQuotes(uo.Name) + " to:", "Change Owner", ""); if (Lex.IsNullOrEmpty(newOwner)) { return(true); } string result = UserObjectUtil.ChangeOwner(uo.Id, newOwner); if (!Lex.IsNullOrEmpty(result)) { MessageBoxMx.Show(result); } return(true); } else if (Lex.Eq(command, "Permissions")) // set object permissions { PermissionsDialog.Show(uo); return(true); } else if (Lex.Eq(command, "ViewSource")) { uo = UserObjectDao.Read(uo); if (uo == null) { return(true); } string ext = ".txt"; // default extension if (uo.Type == UserObjectType.Query || uo.Type == UserObjectType.Annotation) { ext = ".xml"; } string cFile = ClientDirs.TempDir + @"\Source" + ext; StreamWriter sw = new StreamWriter(cFile); sw.Write(uo.Content); sw.Close(); SystemUtil.StartProcess(cFile); // show it } else { return(false); // command not recognized } return(true); // command recognized and processed }
private void ViewSourceMenuItem_Click(object sender, EventArgs e) { UserObjectUtil.ProcessCommonRightClickObjectMenuCommands("ViewSource", CurrentContentsMetaTreeNode, ContentsTreeControl); }
/// <summary> /// Save/SaveAs the list /// </summary> /// <param name="saveAs">SaveAs under another list name</param> /// <param name="saveAsTempList">Save as a temp list</param> /// <param name="tempListName">Temp list name to save under, prompt if null</param> /// <returns></returns> bool Save( bool saveAs, bool saveAsTempList, string tempListName) { if (!ValidateList()) { return(false); // Validate the list if requested } // Get list name if needed & check that user can modify it if (saveAs || CidList.UserObject.Id == 0) { CidList.UserObject.Id = 0; // assign new id if (saveAsTempList) { if (tempListName == null) // prompt for name { tempListName = CidListCommand.PromptForNewTempListName(); if (tempListName == null) { return(false); } } CidList.UserObject = new UserObject(UserObjectType.CnList); CidList.UserObject.ParentFolder = UserObject.TempFolderName; CidList.UserObject.Name = tempListName; CidList.UserObject.Owner = SS.I.UserName; } else // save as permanent list { UserObject existingUo = CidList.UserObject; if (CidList.UserObject.Id == 0) { existingUo = new UserObject(UserObjectType.CnList); } UserObject listUo = UserObjectSaveDialog.Show("Save As", existingUo); if (listUo == null) { return(false); } CidList.UserObject = listUo; } } if (!UserObjectUtil.UserHasWriteAccess(CidList.UserObject)) { // is the user authorized to save this list? MessageBoxMx.ShowError("You are not authorized to save this list"); return(false); } // Write out the list DisplayStatusMsg("Saving list..."); if (CidList.UserObject.HasDefinedParentFolder) { MetaTreeNode targetFolder = UserObjectTree.GetValidUserObjectTypeFolder(CidList.UserObject); if (targetFolder == null) { // shouldn't happen MessageBoxMx.ShowError("The list could not be saved because the folder it was in no longer exists. Please try SaveAs instead."); return(false); } } GetNormalizedListFromControl(CidList); if (!CidList.UserObject.IsCurrentObject) // normal list? { CidListCommand.Write(CidList); } else // special processing for current list { SessionManager.LockResultsKeys = true; // avoid possible overwrite of ResultsKeys if in single step query int rc = CidListCommand.Write(CidList); List <string> curListString = CidListCommand.ReadCurrentListLocal().ToStringList(); SessionManager.CurrentResultKeys = curListString; SessionManager.DisplayCurrentCount(); SessionManager.LockResultsKeys = false; } //string cFile = SS.I.ClientDefaultDir + @"\Previous.lst" //if (UIMisc.CanWriteFileToDefaultDir(cFile)) //{ // StreamWriter sw = new StreamWriter(cFile); // save copy to disk // sw.Write(CidList.UserObject.Content); // sw.Close(); //} int cncnt = CidList.Count; DisplayStatusMsg("List saved"); Before = CidListCtl.Text; string tok = UserObjectUtil.GetName(ListName); Text = "Edit List - [" + CidList.UserObject.Name + "]"; return(true); }
/// <summary> /// Setup for edit /// </summary> /// <param name="inList"></param> /// <param name="rootTable"></param> /// <returns></returns> bool Setup( CidList inList, MetaTable rootTable) { string formattedCid, label, txt; RootTable = rootTable; InListName = inList.UserObject.Name; ListName = InListName; CidList = inList.Clone(); // make copy of list to edit CidCount = InitialCount = CidList.Count; if (CidCount > 32000) // too big to edit? { txt = "The list contains " + CidList.Count.ToString() + " compound numbers which\n" + "exceeds the maximum of 32,000 that can be directly edited.\n" + " Do you want to clear the list and start a new list?"; DialogResult dr = MessageBoxMx.Show(txt, "List Too Large to Edit", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation); if (dr != DialogResult.Yes) { return(false); } CidList = new CidList(); CidList.UserObject = // set name properly UserObjectUtil.ParseInternalUserObjectName(InListName, UserObjectType.CnList); } Text = "Edit List - [" + CidList.UserObject.Name + "]"; Before = FormatList(); // convert & save initial list if (rootTable != null) { label = rootTable.KeyMetaColumn.Label; } else { label = "Compound Id"; } ListLabel.Text = " " + label + " - (Enter one number per line) "; RNLabel.Text = label + ":"; MolCtl.ClearMolecule(); // clear any structure CidCtl.Text = HeavyAtoms.Text = Weight.Text = Formula.Text = ""; CidListCtl.Text = Before; // put text in editor DisplayStatusMsg(""); if (SS.I.AllowGroupingBySalts) { SaltsMenu.Enabled = true; } else { SaltsMenu.Enabled = false; } return(true); }