158
162
// Create Task Pane Items
159
163
m_pTaskPane->UpdateControls();
162
m_pGridPane->Setup();
163
m_pGridPane->SetTable(new CBOINCGridTable(1,7));
164
m_pGridPane->SetSelectionMode(wxGrid::wxGridSelectRows);
166
wxInt32 colSizes[] = {150,80,80,80,80,85,150};
167
wxString colTitles[] = {_("Project"),_("Account"),_("Team"),_("Work done"),_("Avg. work done"),_("Resource share"),_("Status")};
168
for(int i=0; i<= COLUMN_STATUS;i++){
169
m_pGridPane->SetColLabelValue(i,colTitles[i]);
170
m_pGridPane->SetColSize(i,colSizes[i]);
172
//change the default cell renderer
173
m_pGridPane->SetDefaultRenderer(new CBOINCGridCellProgressRenderer(COLUMN_RESOURCESHARE,false));
174
//set column sort types
175
m_pGridPane->SetColumnSortType(COLUMN_TOTALCREDIT,CST_FLOAT);
176
m_pGridPane->SetColumnSortType(COLUMN_RESOURCESHARE,CST_FLOAT);
177
m_pGridPane->SetColumnSortType(COLUMN_AVGCREDIT,CST_FLOAT);
179
m_pGridPane->SetPrimaryKeyColumn(COLUMN_PROJECT);
166
m_pGridPane->Setup();
167
m_pGridPane->SetTable(new CBOINCGridTable(1,NUM_COLUMNS));
168
m_pGridPane->SetSelectionMode(wxGrid::wxGridSelectRows);
170
wxInt32 colSizes[] = {150,80,80,80,80,85,150,0};
171
wxString colTitles[] = {_("Project"),_("Account"),_("Team"),_("Work done"),
172
_("Avg. work done"),_("Resource share"),_("Status"),wxEmptyString
174
for(int i=0; i<NUM_COLUMNS;i++){
175
m_pGridPane->SetColLabelValue(i,colTitles[i]);
176
m_pGridPane->SetColSize(i,colSizes[i]);
178
//change the default cell renderer
179
m_pGridPane->SetDefaultRenderer(new CBOINCGridCellProgressRenderer(COLUMN_RESOURCESHARE,false));
180
//set column sort types
181
m_pGridPane->SetColumnSortType(COLUMN_TOTALCREDIT,CST_FLOAT);
182
m_pGridPane->SetColumnSortType(COLUMN_RESOURCESHARE,CST_FLOAT);
183
m_pGridPane->SetColumnSortType(COLUMN_AVGCREDIT,CST_FLOAT);
185
m_pGridPane->SetPrimaryKeyColumns(COLUMN_HIDDEN_URL,-1);
186
// Hide the URL column
187
int min_width = m_pGridPane->GetColMinimalAcceptableWidth();
188
m_pGridPane->SetColMinimalAcceptableWidth(0);
189
m_pGridPane->SetColSize(COLUMN_HIDDEN_URL,0);
190
m_pGridPane->SetColMinimalAcceptableWidth(min_width);
180
191
UpdateSelection();
246
263
wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
247
264
wxASSERT(m_pGridPane);
251
m_pGridPane->GetCellValue(
252
m_pGridPane->GetFirstSelectedRow(),
256
PROJECT* project = pDoc->project(strProjectName);
258
if (project->suspended_via_gui) {
259
pFrame->UpdateStatusText(_("Resuming project..."));
260
pDoc->ProjectResume(strProjectName);
261
pFrame->UpdateStatusText(wxT(""));
263
pFrame->UpdateStatusText(_("Suspending project..."));
264
pDoc->ProjectSuspend(strProjectName);
265
pFrame->UpdateStatusText(wxT(""));
266
wxArrayInt arrSelRows = m_pGridPane->GetSelectedRows2();
267
n = (int)arrSelRows.GetCount();
271
m_pGridPane->GetCellValue(
276
PROJECT* project = pDoc->project(strProjectURL);
278
if (project->suspended_via_gui) {
279
pFrame->UpdateStatusText(_("Resuming project..."));
280
pDoc->ProjectResume(strProjectURL);
282
pFrame->UpdateStatusText(_("Suspending project..."));
283
pDoc->ProjectSuspend(strProjectURL);
286
pFrame->UpdateStatusText(wxT(""));
268
288
m_bForceUpdateSelection = true;
269
289
UpdateSelection();
286
307
wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
287
308
wxASSERT(m_pGridPane);
291
m_pGridPane->GetCellValue(
292
m_pGridPane->GetFirstSelectedRow(),
296
PROJECT* project = pDoc->project(strProjectName);
310
wxArrayInt arrSelRows = m_pGridPane->GetSelectedRows2();
311
n = (int)arrSelRows.GetCount();
315
m_pGridPane->GetCellValue(
320
PROJECT* project = pDoc->project(strProjectURL);
298
if (project->dont_request_more_work) {
299
pFrame->UpdateStatusText(_("Telling project to allow additional task downloads..."));
300
pDoc->ProjectAllowMoreWork(strProjectName);
301
pFrame->UpdateStatusText(wxT(""));
303
pFrame->UpdateStatusText(_("Telling project to not fetch any additional tasks..."));
304
pDoc->ProjectNoMoreWork(strProjectName);
305
pFrame->UpdateStatusText(wxT(""));
322
if (project->dont_request_more_work) {
323
pFrame->UpdateStatusText(_("Telling project to allow additional task downloads..."));
324
pDoc->ProjectAllowMoreWork(strProjectURL);
326
pFrame->UpdateStatusText(_("Telling project to not fetch any additional tasks..."));
327
pDoc->ProjectNoMoreWork(strProjectURL);
330
pFrame->UpdateStatusText(wxT(""));
308
332
m_bForceUpdateSelection = true;
309
333
UpdateSelection();
310
334
pFrame->FireRefreshView();
336
362
pFrame->UpdateStatusText(_("Resetting project..."));
338
strProjectName = m_pGridPane->GetCellValue(m_pGridPane->GetFirstSelectedRow(), COLUMN_PROJECT);
341
_("Are you sure you want to reset project '%s'?"),
342
strProjectName.c_str()
345
iAnswer = ::wxMessageBox(
348
wxYES_NO | wxICON_QUESTION,
352
if (wxYES == iAnswer) {
353
pDoc->ProjectReset(HtmlEntityEncode(strProjectName.Trim(false)));
364
wxArrayInt arrSelRows = m_pGridPane->GetSelectedRows2();
365
n = (int)arrSelRows.GetCount();
367
strProjectName = m_pGridPane->GetCellValue(arrSelRows[i], COLUMN_PROJECT);
368
strProjectURL = m_pGridPane->GetCellValue(arrSelRows[i], COLUMN_HIDDEN_URL);
371
_("Are you sure you want to reset project '%s'?"),
372
strProjectName.c_str()
375
iAnswer = ::wxMessageBox(
378
wxYES_NO | wxICON_QUESTION,
382
if (wxYES == iAnswer) {
383
pDoc->ProjectReset(HtmlEntityEncode(strProjectURL.Trim(false)));
356
387
pFrame->UpdateStatusText(wxT(""));
358
389
m_bForceUpdateSelection = true;
384
417
pFrame->UpdateStatusText(_("Detaching from project..."));
386
strProjectName = m_pGridPane->GetCellValue(m_pGridPane->GetFirstSelectedRow(), COLUMN_PROJECT);
389
_("Are you sure you want to detach from project '%s'?"),
390
strProjectName.c_str()
393
iAnswer = ::wxMessageBox(
395
_("Detach from Project"),
396
wxYES_NO | wxICON_QUESTION,
400
if (wxYES == iAnswer) {
401
pDoc->ProjectDetach(HtmlEntityEncode(strProjectName.Trim(false)));
419
wxArrayInt arrSelRows = m_pGridPane->GetSelectedRows2();
420
n = (int)arrSelRows.GetCount();
422
strProjectName = m_pGridPane->GetCellValue(arrSelRows[i], COLUMN_PROJECT);
423
strProjectURL = m_pGridPane->GetCellValue(arrSelRows[i], COLUMN_HIDDEN_URL);
426
_("Are you sure you want to detach from project '%s'?"),
427
strProjectName.c_str()
430
iAnswer = ::wxMessageBox(
432
_("Detach from Project"),
433
wxYES_NO | wxICON_QUESTION,
437
if (wxYES == iAnswer) {
438
pDoc->ProjectDetach(HtmlEntityEncode(strProjectURL.Trim(false)));
404
442
pFrame->UpdateStatusText(wxT(""));
406
444
m_bForceUpdateSelection = true;
457
496
m_pGridPane->ClearSelection();
458
497
m_pGridPane->SelectRow(theRow);
462
501
void CViewProjectsGrid::UpdateSelection() {
463
wxString strProjectName = wxEmptyString;
502
wxString strProjectURL = wxEmptyString;
464
503
CTaskItemGroup* pGroup = NULL;
465
504
PROJECT* project = NULL;
466
505
CMainDocument* pDoc = wxGetApp().GetDocument();
507
bool wasSuspended=false, wasNoNewWork=false;
508
static int lastCount = 0;
469
511
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
470
512
wxASSERT(m_pTaskPane);
471
513
wxASSERT(m_pGridPane);
473
if(!m_bForceUpdateSelection) {
515
wxArrayInt arrSelRows = m_pGridPane->GetSelectedRows2();
516
n = (int)arrSelRows.GetCount();
518
// Normally, OnGridSelectRange() is called twice: one for deselecting the previous item
519
// and again for selecting the new item, but occasionally it is not triggered for the
520
// new selection. This hack works around that bug.
521
if (n != lastCount) {
522
m_bForceUpdateSelection = true;
526
if(!m_bForceUpdateSelection) {
477
530
CBOINCBaseView::PreUpdateSelection();
480
533
// Update the tasks static box buttons
482
535
pGroup = m_TaskGroups[0];
538
m_pTaskPane->EnableTaskGroupTasks(pGroup);
540
m_pTaskPane->DisableTaskGroupTasks(pGroup);
541
UpdateWebsiteSelection(GRP_WEBSITES, NULL);
542
if(m_TaskGroups.size()>1) {
543
m_pTaskPane->DisableTaskGroupTasks(m_TaskGroups[1]);
548
strProjectURL = HtmlEntityEncode(
549
m_pGridPane->GetCellValue(arrSelRows[i],COLUMN_HIDDEN_URL).Trim(false)
551
project = pDoc->project(strProjectURL);
553
m_pTaskPane->DisableTaskGroupTasks(pGroup);
554
if(m_TaskGroups.size()>1) {
555
m_pTaskPane->DisableTaskGroupTasks(m_TaskGroups[1]);
484
if (m_pGridPane->GetSelectedRows2().size() == 1) {
487
m_pGridPane->GetCellValue(
488
m_pGridPane->GetFirstSelectedRow(),
492
project = pDoc->project(strProjectName);
493
m_pTaskPane->EnableTask(pGroup->m_Tasks[BTN_UPDATE]);
494
m_pTaskPane->EnableTask(pGroup->m_Tasks[BTN_SUSPEND]);
496
if (project->suspended_via_gui) {
561
wasSuspended = project->suspended_via_gui;
562
if (project->suspended_via_gui) {
497
563
m_pTaskPane->UpdateTask(
498
564
pGroup->m_Tasks[BTN_SUSPEND], _("Resume"), _("Resume tasks for this project.")
514
587
pGroup->m_Tasks[BTN_NOWORK], _("No new tasks"), _("Don't fetch new tasks for this project.")
591
if (wasNoNewWork != project->dont_request_more_work) {
592
// Disable Allow New Work / No New Work button if the multiple
593
// selection has a mix of Allow New Work and No New Work projects
594
m_pTaskPane->DisableTask(pGroup->m_Tasks[BTN_NOWORK]);
518
m_pTaskPane->EnableTask(pGroup->m_Tasks[BTN_RESET]);
519
if (project && project->attached_via_acct_mgr) {
598
if (project->attached_via_acct_mgr) {
520
599
m_pTaskPane->DisableTask(pGroup->m_Tasks[BTN_DETACH]);
603
UpdateWebsiteSelection(GRP_WEBSITES, project);
604
if(m_TaskGroups.size()>1) {
605
m_pTaskPane->EnableTaskGroupTasks(m_TaskGroups[1]);
522
m_pTaskPane->EnableTask(pGroup->m_Tasks[BTN_DETACH]);
608
UpdateWebsiteSelection(GRP_WEBSITES, NULL);
609
if(m_TaskGroups.size()>1) {
610
m_pTaskPane->DisableTaskGroupTasks(m_TaskGroups[1]);
525
UpdateWebsiteSelection(GRP_WEBSITES, project);
528
m_pTaskPane->DisableTaskGroupTasks(pGroup);
529
//disable website buttons if they exist
530
if(m_TaskGroups.size()>1) {
531
m_pTaskPane->DisableTaskGroupTasks(m_TaskGroups[1]);
535
615
CBOINCBaseView::PostUpdateSelection();
536
m_bForceUpdateSelection=false;
617
m_bForceUpdateSelection=false;
539
620
void CViewProjectsGrid::UpdateWebsiteSelection(long lControlGroup, PROJECT* project){
547
628
// Update the websites list
549
if (m_TaskGroups.size() > 1) {
551
// Delete task group, objects, and controls.
552
pGroup = m_TaskGroups[lControlGroup];
554
m_pTaskPane->DeleteTaskGroupAndTasks(pGroup);
555
for (i=0; i<pGroup->m_Tasks.size(); i++) {
556
delete pGroup->m_Tasks[i];
630
if (m_bForceUpdateSelection) {
631
if (m_TaskGroups.size() > 1) {
633
// Delete task group, objects, and controls.
634
pGroup = m_TaskGroups[lControlGroup];
636
m_pTaskPane->DeleteTaskGroupAndTasks(pGroup);
637
for (i=0; i<pGroup->m_Tasks.size(); i++) {
638
delete pGroup->m_Tasks[i];
640
pGroup->m_Tasks.clear();
645
m_TaskGroups.erase( m_TaskGroups.begin() + 1 );
558
pGroup->m_Tasks.clear();
563
m_TaskGroups.erase( m_TaskGroups.begin() + 1 );
566
// If something is selected create the tasks and controls
567
if (m_pGridPane->GetSelectedRows2().size()==1) {
569
// Create the web sites task group
570
pGroup = new CTaskItemGroup( _("Web sites") );
571
m_TaskGroups.push_back( pGroup );
573
// Default project url
574
pItem = new CTaskItem(
575
wxString(project->project_name.c_str(), wxConvUTF8),
577
wxString(project->master_url.c_str(), wxConvUTF8),
578
ID_TASK_PROJECT_WEB_PROJDEF_MIN
580
pGroup->m_Tasks.push_back(pItem);
583
// Project defined urls
584
for (i=0;(i<project->gui_urls.size())&&(i<=ID_TASK_PROJECT_WEB_PROJDEF_MAX);i++) {
648
// If something is selected create the tasks and controls
649
if (m_pGridPane->GetSelectedRows2().size() == 1) {
651
// Create the web sites task group
652
pGroup = new CTaskItemGroup( _("Web sites") );
653
m_TaskGroups.push_back( pGroup );
655
// Default project url
585
656
pItem = new CTaskItem(
586
wxGetTranslation(wxString(project->gui_urls[i].name.c_str(), wxConvUTF8)),
587
wxGetTranslation(wxString(project->gui_urls[i].description.c_str(), wxConvUTF8)),
588
wxString(project->gui_urls[i].url.c_str(), wxConvUTF8),
589
ID_TASK_PROJECT_WEB_PROJDEF_MIN + 1 + i
657
wxString(project->project_name.c_str(), wxConvUTF8),
659
wxString(project->master_url.c_str(), wxConvUTF8),
660
ID_TASK_PROJECT_WEB_PROJDEF_MIN
591
662
pGroup->m_Tasks.push_back(pItem);
665
// Project defined urls
666
for (i=0;(i<project->gui_urls.size())&&(i<=ID_TASK_PROJECT_WEB_PROJDEF_MAX);i++) {
667
pItem = new CTaskItem(
668
wxGetTranslation(wxString(project->gui_urls[i].name.c_str(), wxConvUTF8)),
669
wxGetTranslation(wxString(project->gui_urls[i].description.c_str(), wxConvUTF8)),
670
wxString(project->gui_urls[i].url.c_str(), wxConvUTF8),
671
ID_TASK_PROJECT_WEB_PROJDEF_MIN + 1 + i
673
pGroup->m_Tasks.push_back(pItem);
678
m_bForceUpdateSelection = false;
771
864
if(docCount != m_pGridPane->GetNumberRows()) {
772
865
if (docCount > m_pGridPane->GetNumberRows()) {
773
866
m_pGridPane->AppendRows(docCount - m_pGridPane->GetNumberRows());
775
m_pGridPane->DeleteRows(0, m_pGridPane->GetNumberRows() - docCount);
868
m_pGridPane->DeleteRows(0, m_pGridPane->GetNumberRows() - docCount);
869
m_bForceUpdateSelection = true;
777
871
wxASSERT(docCount == m_pGridPane->GetNumberRows());
781
int iMax = m_pGridPane->GetNumberRows();
782
for(int iRow = 0; iRow < iMax; iRow++) {
874
m_bIgnoreUIEvents = true;
875
m_pGridPane->SaveSelection();
876
m_bIgnoreUIEvents = false;
879
int iMax = m_pGridPane->GetNumberRows();
880
for(int iRow = 0; iRow < iMax; iRow++) {
784
882
FormatProjectName(iRow, strBuffer);
785
883
if (m_pGridPane->GetCellValue(iRow, COLUMN_PROJECT) != strBuffer) {
786
m_pGridPane->SetCellValue(iRow, COLUMN_PROJECT, strBuffer);
884
m_pGridPane->SetCellValue(iRow, COLUMN_PROJECT, strBuffer);
789
FormatAccountName(iRow, strBuffer);
887
FormatAccountName(iRow, strBuffer);
790
888
if (m_pGridPane->GetCellValue(iRow, COLUMN_ACCOUNTNAME) != strBuffer) {
791
m_pGridPane->SetCellValue(iRow, COLUMN_ACCOUNTNAME, strBuffer);
889
m_pGridPane->SetCellValue(iRow, COLUMN_ACCOUNTNAME, strBuffer);
794
FormatTeamName(iRow, strBuffer);
892
FormatTeamName(iRow, strBuffer);
795
893
if (m_pGridPane->GetCellValue(iRow, COLUMN_TEAMNAME) != strBuffer) {
796
m_pGridPane->SetCellValue(iRow, COLUMN_TEAMNAME, strBuffer);
894
m_pGridPane->SetCellValue(iRow, COLUMN_TEAMNAME, strBuffer);
799
FormatTotalCredit(iRow, strBuffer);
897
FormatTotalCredit(iRow, strBuffer);
800
898
if (m_pGridPane->GetCellValue(iRow, COLUMN_TOTALCREDIT) != strBuffer) {
801
m_pGridPane->SetCellValue(iRow, COLUMN_TOTALCREDIT, strBuffer);
899
m_pGridPane->SetCellValue(iRow, COLUMN_TOTALCREDIT, strBuffer);
804
FormatAVGCredit(iRow, strBuffer);
902
FormatAVGCredit(iRow, strBuffer);
805
903
if (m_pGridPane->GetCellValue(iRow, COLUMN_AVGCREDIT) != strBuffer) {
806
m_pGridPane->SetCellValue(iRow, COLUMN_AVGCREDIT, strBuffer);
904
m_pGridPane->SetCellValue(iRow, COLUMN_AVGCREDIT, strBuffer);
809
FormatResourceShare(iRow, strBuffer);
907
FormatResourceShare(iRow, strBuffer);
810
908
if (m_pGridPane->GetCellValue(iRow, COLUMN_RESOURCESHARE) != strBuffer) {
811
m_pGridPane->SetCellValue(iRow, COLUMN_RESOURCESHARE, strBuffer);
812
m_pGridPane->SetCellAlignment(iRow, COLUMN_RESOURCESHARE, wxALIGN_CENTRE, wxALIGN_CENTRE);
909
m_pGridPane->SetCellValue(iRow, COLUMN_RESOURCESHARE, strBuffer);
910
m_pGridPane->SetCellAlignment(iRow, COLUMN_RESOURCESHARE, wxALIGN_CENTRE, wxALIGN_CENTRE);
815
strBuffer = wxEmptyString;
816
FormatStatus(iRow, strBuffer);
913
strBuffer = wxEmptyString;
914
FormatStatus(iRow, strBuffer);
817
915
if (m_pGridPane->GetCellValue(iRow, COLUMN_STATUS) != strBuffer) {
818
m_pGridPane->SetCellValue(iRow, COLUMN_STATUS, strBuffer);
916
m_pGridPane->SetCellValue(iRow, COLUMN_STATUS, strBuffer);
919
FormatProjectURL(iRow, strBuffer);
920
if (m_pGridPane->GetCellValue(iRow, COLUMN_HIDDEN_URL) != strBuffer) {
921
m_pGridPane->SetCellValue(iRow, COLUMN_HIDDEN_URL, strBuffer);
822
925
m_pGridPane->SortData();
927
m_bIgnoreUIEvents = true;
928
m_pGridPane->RestoreSelection();
929
m_bIgnoreUIEvents = false;
826
933
wxLogTrace(wxT("Function Start/End"), wxT("CViewProjectsGrid::OnListRender - Function End"));