MetaTreeNodeType GetNodeTypesToSearch() { MetaTreeNodeType nodeTypes = 0; if (Folders.Checked) { nodeTypes |= MetaTreeNodeType.FolderMask; // all folder types } if (MetaTables.Checked) { nodeTypes |= MetaTreeNodeType.MetaTable; } if (AnnotationTables.Checked) { nodeTypes |= MetaTreeNodeType.Annotation; } if (CalcFields.Checked) { nodeTypes |= MetaTreeNodeType.CalcField; } if (Queries.Checked) { nodeTypes |= MetaTreeNodeType.Query; } if (CidLists.Checked) { nodeTypes |= MetaTreeNodeType.CnList; } if (HyperLinks.Checked) { nodeTypes |= MetaTreeNodeType.Url; } return(nodeTypes); }
/// <summary> /// Return true if leaf type node /// </summary> /// <param name="type"></param> /// <returns></returns> public static bool IsLeafNodeType( MetaTreeNodeType type) { bool isLeaf = (type & MetaTreeNodeType.LeafMask) != 0; //if (!isLeaf && type >= MetaTreeNodeType.MetaTable) type = type; // debug return(isLeaf); }
public static bool IsFolderNodeType( MetaTreeNodeType type) { bool isFolder = (type & MetaTreeNodeType.FolderMask) != 0; //if (!isFolder && type < MetaTreeNodeType.FolderFree) type = type; // debug return(isFolder); }
void SetNodeTypesToSearch(MetaTreeNodeType nodeTypes) { Folders.Checked = ((nodeTypes & MetaTreeNodeType.FolderMask) != 0) ? true : false; MetaTables.Checked = ((nodeTypes & MetaTreeNodeType.MetaTable) != 0) ? true : false; AnnotationTables.Checked = ((nodeTypes & MetaTreeNodeType.Annotation) != 0) ? true : false; CalcFields.Checked = ((nodeTypes & MetaTreeNodeType.CalcField) != 0) ? true : false; Queries.Checked = ((nodeTypes & MetaTreeNodeType.Query) != 0) ? true : false; CidLists.Checked = ((nodeTypes & MetaTreeNodeType.CnList) != 0) ? true : false; HyperLinks.Checked = ((nodeTypes & MetaTreeNodeType.Url) != 0) ? true : false; }
public static bool IsDataTableNodeType( MetaTreeNodeType type) { if ((type & MetaTreeNodeType.DataTableTypes) != 0) { return(true); } else { return(false); } }
public static bool IsMultiSelectableNodeType( MetaTreeNodeType type) { switch (type) { case MetaTreeNodeType.Annotation: case MetaTreeNodeType.CalcField: case MetaTreeNodeType.MetaTable: case MetaTreeNodeType.CnList: case MetaTreeNodeType.Query: return(true); default: return(false); } }
/// <summary> /// Select a single item from the filtered types from the contents tree /// </summary> /// <param name="title"></param> /// <param name="prompt"></param> /// <param name="typeFilter"></param> /// <param name="initialSelection"></param> /// <param name="numberItems"></param> /// <returns></returns> public static MetaTreeNode SelectSingleItem( string title, string prompt, MetaTreeNodeType typeFilter, MetaTreeNode initialSelection, bool numberItems) { if (Instance == null) { Instance = new SelectFromContents(); } Instance.Text = title; Instance.Prompt.Text = prompt; string selectedNodeTarget = (initialSelection != null ? initialSelection.Target : null); string expandNodeTarget = ContentsTreeControl.GetPreferredProjectNodeTarget(); Instance.ContentsTree.FillTree( "root", typeFilter, selectedNodeTarget, expandNodeTarget, null, false, false); Instance.ContentsTreeWithSearch.CommandLineControl.Text = ""; Instance.SelectionName.Text = (initialSelection != null ? initialSelection.Label : null); Instance.SelectionTarget.Text = (initialSelection != null ? initialSelection.Target : null); Instance.TypeFilter = typeFilter; QbUtil.SetProcessTreeItemOperationMethod(TreeItemOperation); DialogResult dr = Instance.ShowDialog(SessionManager.ActiveForm); QbUtil.RestoreProcessTreeItemOperationMethod(); if (dr == DialogResult.Cancel) { return(null); } MetaTreeNode mtn = Instance.ContentsTree.FocusedMetaTreeNode; return(mtn); }
/// <summary> /// Return true if the specified type is a user object node type /// </summary> /// <param name="type"></param> /// <returns></returns> public static bool IsUserObjectNodeType( MetaTreeNodeType type) { switch (type) { case MetaTreeNodeType.CnList: case MetaTreeNodeType.Query: case MetaTreeNodeType.Annotation: case MetaTreeNodeType.CalcField: case MetaTreeNodeType.CondFormat: case MetaTreeNodeType.UserFolder: return(true); default: return(false); } }
/// <summary> /// Parse a node type/name string (e.g. "TABLE QUERY_1234") into a node type & name /// </summary> /// <param name="typeAndTarget"></param> /// <param name="type"></param> /// <param name="name"></param> public static void ParseTypeAndNameString( string typeAndTarget, out MetaTreeNodeType type, out string name) { type = MetaTreeNodeType.Unknown; name = null; int i1 = typeAndTarget.IndexOf(" "); if (i1 >= 0) { string typeName = typeAndTarget.Substring(0, i1); type = MetaTreeNode.ParseTypeString(typeName); name = typeAndTarget.Substring(i1 + 1); } else // no type supplied { type = MetaTreeNodeType.Unknown; name = typeAndTarget; } return; }
/// <summary> /// Open the specified target /// </summary> /// <param name="mtn"></param> public static void OpenMetaTreeNode( MetaTreeNode mtn) { UserObject uo; string tok; int i1; if (mtn == null) { return; } MetaTreeNodeType nodeType = mtn.Type; string target = mtn.Target; //if (!Permissions.UserHasReadAccess(SS.I.UserName, target)) //{ // MessageBoxMx.ShowError("You are not authorized to open: " + mtn.Label); // return; //} if (nodeType == MetaTreeNodeType.MetaTable || // data table types nodeType == MetaTreeNodeType.CalcField || nodeType == MetaTreeNodeType.Annotation || nodeType == MetaTreeNodeType.ResultsView) { QbUtil.AddAndRenderTables(target); //.CallCurrentProcessTreeItemOperationMethod("Open", target); } else if (nodeType == MetaTreeNodeType.CondFormat) { uo = ParseAndReadUserObject(mtn.Name); if (uo == null) { return; } tok = uo.InternalName; CondFormatEditor.EditUserObject(uo.InternalName); } else if (MetaTreeNode.IsFolderNodeType(nodeType)) { if (Lex.StartsWith(target, "USERDATABASE_")) // edit a user compound database { uo = ParseAndReadUserObject(target); if (uo == null) { return; } UserData.OpenExistingUserDatabase(uo); } } else if (nodeType == MetaTreeNodeType.Url) { // open url or execute click function if ((i1 = Lex.IndexOf(target, "ClickFunction")) >= 0) { string cmd = target.Substring(i1 + "ClickFunction".Length + 1); // get function name ClickFunctions.Process(cmd, null); } else if (Lex.Contains(target, "SpotfireWeb")) // link to Spotfire webplayer { SpotfireLinkUI.OpenLink(target); } else { SystemUtil.StartProcess(target); // open in default user browser } } else if (nodeType == MetaTreeNodeType.Action) { // execute action CommandLine.Execute(mtn.Target); } else if (nodeType == MetaTreeNodeType.CnList) // open list { uo = ParseAndReadUserObject(target); if (uo == null) { return; } tok = uo.InternalName; CidListEditor.Edit(tok); } else if (nodeType == MetaTreeNodeType.Query) // open query { uo = ParseAndReadUserObject(target); if (uo == null) { return; } if (uo.Type == UserObjectType.Query) // normal query { tok = uo.InternalName; string nextCommand = QbUtil.OpenQuery(tok); while (!(String.IsNullOrEmpty(nextCommand))) { nextCommand = CommandExec.ExecuteCommand(nextCommand); } } else if (uo.Type == UserObjectType.MultiTable) // multitable query { QbUtil.AddAndRenderTables(target); } } else if (nodeType == MetaTreeNodeType.Library) { CommandExec.ExecuteCommandAsynch("ContentsViewLibAsList " + mtn.Name); } }
/// <summary> /// Validate the selection /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OK_Click(object sender, EventArgs e) { UserObjectType type; int id; if (ObjectName.Text == "") { MessageBoxMx.Show("A name must be supplied", UmlautMobius.String, MessageBoxButtons.OK); return; } if (SelectedNode != null) // selected from tree { UserObject.ParseObjectTypeAndIdFromInternalName(SelectedNode.Target, out type, out id); OpenUoInfo = UserObjectDao.ReadHeader(id); DialogResult = DialogResult.OK; return; } else // name typed in, determine the location { MetaTreeNode folderNode = ContentsTreeWithSearch.ContentsTreeCtl.FocusedMetaTreeNode; bool foundFolder = false; while (folderNode != null) { if (folderNode.IsFolderType) { foundFolder = true; break; } folderNode = folderNode.Parent; // move up in tree } if (!foundFolder) { // could not determine where to look for the object MessageBoxMx.Show("You must select the folder in which " + ObjectName.Text + " is to be found!", "Which Folder?", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); DialogResult = DialogResult.None; return; } else { // have a folder, look for entered name string folderTarget = folderNode.Target; if (!UserObjectTree.FolderNodes.ContainsKey(folderTarget)) { MessageBoxMx.ShowError("Unexpected error - Failed to find folder: " + folderTarget); return; } MetaTreeNode mtn = UserObjectTree.FolderNodes[folderTarget]; MetaTreeNodeType mtnType = UserObjectTree.UserObjectTypeToMetaTreeNodeType(UoType); mtn = UserObjectTree.GetNodeByLabel(mtn, mtnType, ObjectName.Text); if (mtn != null) { UserObject.ParseObjectTypeAndIdFromInternalName(mtn.Target, out type, out id); OpenUoInfo = UserObjectDao.ReadHeader(id); DialogResult = DialogResult.OK; } else { string msg = ObjectName.Text + "\n" + "File not found.\n" + "Please verify that the correct name was given."; MessageBoxMx.Show(msg, Instance.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); DialogResult = DialogResult.None; return; } } } }
/// <summary> /// Construct with type /// </summary> /// <param name="type"></param> public MetaTreeNode(MetaTreeNodeType type) { Nodes = new List <MetaTreeNode>(); Type = type; return; }
/// <summary> /// Return true if the specified type is a sustem node type /// </summary> /// <param name="type"></param> /// <returns></returns> public static bool IsSystemNodeType( MetaTreeNodeType type) { return(!IsUserObjectNodeType(type)); }