/// <summary> /// /// </summary> /// <param name="text"></param> private void UpdateGraphByQuery(string text) { _graph.Edges.Clear(); PolarionItem[] polarionItems = PolarionItem.GetItemsFromQuery(text); if (polarionItems == null) { _graph.Edges.Clear(); return; } foreach (PolarionItem polarionItem in polarionItems) { if (polarionItem.WorkItem == null) { continue; } foreach (PolarionItem polarionChildItem in polarionItem.Childs) { _graph.AddEdge($"{polarionItem.WorkItem.id}-{polarionItem.WorkItem.title}", $"{polarionChildItem.WorkItem.id}-{polarionChildItem.WorkItem.title}"); Node node = _graph.FindNode($"{polarionChildItem.WorkItem.id}-{polarionChildItem.WorkItem.title}"); node.UserData = polarionChildItem; Color color = Color.White; if (polarionChildItem.WorkItem.type != null) { color = cyclicColorConfiguration.GetColor(polarionChildItem.WorkItem.type.id); } NodeStyle nodeStyle = new NodeStyle(color); nodeStyle.ApplyToNode(node); } Node mainNode = _graph.FindNode($"{polarionItem.WorkItem.id}-{polarionItem.WorkItem.title}"); if (mainNode != null) { mainNode.UserData = polarionItem; } else { //we shouldn't get here normally. } } _gviewer.Graph = null; _gviewer.Graph = _graph; }
public static PolarionItem[] CreateItems(string type, string text) { string[] lines = Regex.Split(text, "\n"); List <PolarionItem> polarionItems = new List <PolarionItem>(); foreach (string line in lines) { string changedLine = line.Replace("/", "").TrimStart(' '); TrackerService.WorkItem workItem = API.CreateWorkItem("type", changedLine); PolarionItem polarionItem = new PolarionItem(workItem.id); polarionItems.Add(polarionItem); } return(polarionItems.ToArray()); }
/// <summary> /// /// </summary> public PolarionViewerForm() { cyclicColorConfiguration.Assign.Add("testPlan", Color.Gray); cyclicColorConfiguration.Assign.Add("meeting", Color.White); cyclicColorConfiguration.Assign.Add("testCaseAutomatic", Color.Blue); cyclicColorConfiguration.Assign.Add("problemReport", Color.Orange); cyclicColorConfiguration.Assign.Add("bildPipeline", Color.Azure); InitializeComponent(); InitializeGraph(); _host.Child = _viewer; _host.Dock = DockStyle.Fill; _host.Parent = splitContainer1.Panel2; bool isConnected = API.Connect(polarionMainURL, "sw.project.automation", "Codanargus1234"); if (!isConnected) { MessageBox.Show("Couldn't connect to polarion."); } string query = textBoxQuery.Text; textBoxQuery.KeyDown += delegate(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return) { Thread thread = new Thread(new ThreadStart(NoParamsDelegateThread)); bool useThreads = true; if (useThreads) { thread.Start(); } else { NoParamsDelegateNoThread(); } cobQueryHistory.Items.Add(textBoxQuery.Text); } }; _viewer.Child = _gviewer; cobQueryHistory.SelectedIndexChanged += delegate(object sender, EventArgs e) { string selectedQuery = cobQueryHistory.SelectedItem as string; if (string.IsNullOrEmpty(selectedQuery)) { textBoxQuery.Text = selectedQuery; } }; _gviewer.MouseDown += delegate(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { this.contextMenuStrip1.Show(PointToScreen(e.Location)); } }; _gviewer.MouseClick += delegate(object sender, MouseEventArgs e) { GViewer viewer = sender as GViewer; if (!(viewer.SelectedObject is Node)) { return; } Node node = viewer.SelectedObject as Node; PolarionItem polarionItem = node.UserData as PolarionItem; _LastSelectedNode = node; _LastSelectedPolarionItem = polarionItem; _LastSelectedURI = Helper.GetURI(polarionItem.WorkItem.uri); this.propertyGrid1.SelectedObject = polarionItem.WorkItem; }; _gviewer.MouseDoubleClick += delegate(object sender, MouseEventArgs e) { GViewer viewer = sender as GViewer; if (!(viewer.SelectedObject is Node)) { return; } Node node = viewer.SelectedObject as Node; PolarionItem polarionItem = node.UserData as PolarionItem; string uri = Helper.GetURI(polarionItem.WorkItem.uri); if (string.IsNullOrEmpty(uri)) { return; } Process.Start(uri); //...do works here }; }