Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/jqlondemand'
Browse files Browse the repository at this point in the history
  • Loading branch information
carstengehling committed Apr 18, 2016
2 parents 37e3bdc + 0b085b7 commit 209ad44
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 31 deletions.
67 changes: 58 additions & 9 deletions source/StopWatch/IssueControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,6 @@ public IssueControl(JiraClient jiraClient, Settings settings)
{
InitializeComponent();

cbJira.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
cbJira.DropDownStyle = ComboBoxStyle.DropDown;
cbJira.DrawMode = DrawMode.OwnerDrawVariable;
cbJira.DrawItem += cbJira_DrawItem;
cbJira.MeasureItem += cbJira_MeasureItem;
cbJira.SelectedIndexChanged += cbJira_SelectedIndexChanged;
cbJira.DisplayMember = "Key";
cbJira.ValueMember = "Key";

ignoreTextChange = false;

Comment = null;
Expand Down Expand Up @@ -200,7 +191,19 @@ private void InitializeComponent()
this.cbJira.Name = "cbJira";
this.cbJira.Size = new System.Drawing.Size(155, 28);
this.cbJira.TabIndex = 0;
this.cbJira.DropDown += new System.EventHandler(this.cbJira_DropDown);
this.cbJira.Leave += new System.EventHandler(this.cbJira_Leave);
this.cbJira.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
this.cbJira.DropDownStyle = ComboBoxStyle.DropDown;
this.cbJira.DrawMode = DrawMode.OwnerDrawVariable;
this.cbJira.IntegralHeight = false;
this.cbJira.DropDownHeight = 90;
this.cbJira.DrawItem += cbJira_DrawItem;
this.cbJira.MeasureItem += cbJira_MeasureItem;
this.cbJira.SelectedIndexChanged += cbJira_SelectedIndexChanged;
this.cbJira.DisplayMember = "Key";
this.cbJira.ValueMember = "Key";

//
// tbTime
//
Expand Down Expand Up @@ -358,6 +361,11 @@ void cbJira_DrawItem(object sender, DrawItemEventArgs e)
// Draw the text on the second column
using (SolidBrush sb = new SolidBrush(e.ForeColor))
e.Graphics.DrawString(item.Summary, font, sb, r2);

// Draw a line to isolate the columns
using (Pen p = new Pen(Color.Black))
e.Graphics.DrawLine(p, r1.Right, 0, r1.Right, 140);

}


Expand All @@ -367,6 +375,12 @@ void cbJira_SelectedIndexChanged(object sender, EventArgs e)
}


private void cbJira_DropDown(object sender, EventArgs e)
{
LoadIssues();
}


private void btnOpen_Click(object sender, EventArgs e)
{
OpenJira(cbJira.Text);
Expand Down Expand Up @@ -485,6 +499,41 @@ private void PostAndReset(string key, TimeSpan timeElapsed, string comment)
}
);
}


private void LoadIssues()
{
// TODO: This + the datasource for cbFilters should be moved into a controller layer

var ctrlList = (Parent as MainForm).Controls.Find("cbFilters", false);
if (ctrlList.Length == 0)
return;

var cbFilters = ctrlList[0] as ComboBox;
if (cbFilters.SelectedIndex < 0)
return;

string jql = (cbFilters.SelectedItem as CBFilterItem).Jql;

Task.Factory.StartNew(
() =>
{
List<Issue> availableIssues = jiraClient.GetIssuesByJQL(jql).Issues;
if (availableIssues == null)
return;
this.InvokeIfRequired(
() =>
{
AvailableIssues = availableIssues;
cbJira.DropDownHeight = 120;
cbJira.Invalidate();
}
);
}
);
}
#endregion


Expand Down
1 change: 1 addition & 0 deletions source/StopWatch/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 10 additions & 22 deletions source/StopWatch/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,32 +190,19 @@ private void pbLogin_Click(object sender, EventArgs e)
}


private void cbFilters_DropDown(object sender, EventArgs e)
{
LoadFilters();
}


private void cbFilters_SelectedIndexChanged(object sender, EventArgs e)
{
var item = (CBFilterItem)cbFilters.SelectedItem;
this.settings.CurrentFilter = item.Id;

string jql = item.Jql;

Task.Factory.StartNew(
() =>
{
List<Issue> availableIssues = jiraClient.GetIssuesByJQL(jql).Issues;
if (availableIssues == null)
return;
this.InvokeIfRequired(
() =>
{
foreach (var issueControl in this.issueControls)
issueControl.AvailableIssues = availableIssues;
}
);
}
);
}


private void MainForm_Resize(object sender, EventArgs e)
{
// Mono for MacOSX and Linux do not implement the notifyIcon
Expand Down Expand Up @@ -373,7 +360,8 @@ private void UpdateJiraRelatedData(bool firstTick)
lblConnectionStatus.Text = "Connected";
lblConnectionStatus.ForeColor = Color.DarkGreen;
LoadFilterList();
if (firstTick)
LoadFilters();
UpdateIssuesOutput(firstTick);
}
Expand Down Expand Up @@ -462,7 +450,7 @@ private void JiraLogin()
}


private void LoadFilterList()
private void LoadFilters()
{
Task.Factory.StartNew(
() =>
Expand Down

0 comments on commit 209ad44

Please sign in to comment.