~ubuntu-branches/ubuntu/lucid/boinc/lucid

« back to all changes in this revision

Viewing changes to clientgui/ViewProjectsGrid.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Frank S. Thomas, Frank S. Thomas
  • Date: 2008-05-31 08:02:47 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20080531080247-4ce890lp2rc768cr
Tags: 6.2.7-1
[ Frank S. Thomas ]
* New upstream release.
  - BOINC Manager: Redraw disk usage charts immediately after connecting to
    a (different) client. (closes: 463823)
* debian/copyright:
  - Added the instructions from debian/README.Debian-source about how
    repackaged BOINC tarballs can be reproduced because DevRef now
    recommends to put this here instead of in the afore-mentioned file.
  - Updated for the new release.
* Removed the obsolete debian/README.Debian-source.
* For consistency upstream renamed the core client and the command tool
  ("boinc_client" to "boinc" and "boinc_cmd" to "boinccmd"). Done the same
  in all packages and created symlinks with the old names for the binaries
  and man pages. Also added an entry in debian/boinc-client.NEWS explaining
  this change.
* debian/rules: Do not list Makefile.ins in the clean target individually,
  just remove all that can be found.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
// To view the GNU Lesser General Public License visit
16
16
// http://www.gnu.org/copyleft/lesser.html
17
17
// or write to the Free Software Foundation, Inc.,
18
 
// 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 
20
20
#if defined(__GNUG__) && !defined(__APPLE__)
21
21
#pragma implementation "ViewProjectsGrid.h"
43
43
#define COLUMN_AVGCREDIT            4
44
44
#define COLUMN_RESOURCESHARE        5
45
45
#define COLUMN_STATUS               6
 
46
#define COLUMN_HIDDEN_URL           7
 
47
#define NUM_COLUMNS                 (COLUMN_HIDDEN_URL+1)
46
48
 
47
49
// groups that contain buttons
48
50
#define GRP_TASKS    0
67
69
    EVT_CUSTOM_RANGE(wxEVT_COMMAND_BUTTON_CLICKED, ID_TASK_PROJECT_WEB_PROJDEF_MIN, ID_TASK_PROJECT_WEB_PROJDEF_MAX, CViewProjectsGrid::OnProjectWebsiteClicked)
68
70
        EVT_GRID_SELECT_CELL(CViewProjectsGrid::OnGridSelectCell)
69
71
        EVT_GRID_RANGE_SELECT(CViewProjectsGrid::OnGridSelectRange)
 
72
#if PREVENT_MULTIPLE_PROJECT_SELECTIONS
70
73
        EVT_GRID_CELL_LEFT_CLICK(CViewProjectsGrid::OnCellLeftClick)
 
74
#endif
71
75
END_EVENT_TABLE ()
72
76
 
73
77
 
158
162
    // Create Task Pane Items
159
163
    m_pTaskPane->UpdateControls();
160
164
 
161
 
        // Create Grid
162
 
        m_pGridPane->Setup();
163
 
        m_pGridPane->SetTable(new CBOINCGridTable(1,7));
164
 
        m_pGridPane->SetSelectionMode(wxGrid::wxGridSelectRows);
165
 
        // init grid columns
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]);
171
 
        }
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);
178
 
        //
179
 
        m_pGridPane->SetPrimaryKeyColumn(COLUMN_PROJECT);
 
165
    // Create Grid
 
166
    m_pGridPane->Setup();
 
167
    m_pGridPane->SetTable(new CBOINCGridTable(1,NUM_COLUMNS));
 
168
    m_pGridPane->SetSelectionMode(wxGrid::wxGridSelectRows);
 
169
    // init grid columns
 
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
 
173
                            };
 
174
    for(int i=0; i<NUM_COLUMNS;i++){
 
175
            m_pGridPane->SetColLabelValue(i,colTitles[i]);
 
176
            m_pGridPane->SetColSize(i,colSizes[i]);
 
177
    }
 
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);
 
184
    //
 
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();
181
192
}
182
193
 
206
217
void CViewProjectsGrid::OnProjectUpdate( wxCommandEvent& WXUNUSED(event) ) {
207
218
    wxLogTrace(wxT("Function Start/End"), wxT("CViewProjectsGrid::OnProjectUpdate - Function Begin"));
208
219
 
209
 
    wxString        strProjectName = wxEmptyString;
 
220
    wxString        strProjectURL  = wxEmptyString;
210
221
    CMainDocument*  pDoc           = wxGetApp().GetDocument();
211
222
    CAdvancedFrame* pFrame         = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
 
223
    int i, n;
212
224
 
213
225
    wxASSERT(pDoc);
214
226
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
218
230
 
219
231
    pFrame->UpdateStatusText(_("Updating project..."));
220
232
 
221
 
    strProjectName = m_pGridPane->GetCellValue(m_pGridPane->GetFirstSelectedRow(), COLUMN_PROJECT);
222
 
 
223
 
    pDoc->ProjectUpdate(HtmlEntityEncode(strProjectName).Trim(false));
224
 
 
 
233
    wxArrayInt arrSelRows = m_pGridPane->GetSelectedRows2();    
 
234
    n = (int)arrSelRows.GetCount();
 
235
    for(i=0; i<n; i++) {
 
236
        strProjectURL = m_pGridPane->GetCellValue(arrSelRows[i], COLUMN_HIDDEN_URL);
 
237
 
 
238
        pDoc->ProjectUpdate(HtmlEntityEncode(strProjectURL).Trim(false));
 
239
    }
 
240
    
225
241
    pFrame->UpdateStatusText(wxT(""));
226
242
 
227
243
    m_bForceUpdateSelection = true;
236
252
void CViewProjectsGrid::OnProjectSuspend( wxCommandEvent& WXUNUSED(event) ) {
237
253
    wxLogTrace(wxT("Function Start/End"), wxT("CViewProjectsGrid::OnProjectSuspend - Function Begin"));
238
254
 
239
 
    wxString        strProjectName = wxEmptyString;
 
255
    wxString        strProjectURL  = wxEmptyString;
240
256
    CMainDocument*  pDoc           = wxGetApp().GetDocument();
241
257
    CAdvancedFrame* pFrame         = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
 
258
    int i, n;
242
259
 
243
260
    wxASSERT(pDoc);
244
261
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
246
263
    wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
247
264
    wxASSERT(m_pGridPane);
248
265
 
249
 
    strProjectName = 
250
 
        HtmlEntityEncode(
251
 
            m_pGridPane->GetCellValue(
252
 
                m_pGridPane->GetFirstSelectedRow(),
253
 
                COLUMN_PROJECT
254
 
            ).Trim(false)
255
 
        );
256
 
    PROJECT* project = pDoc->project(strProjectName);
257
 
 
258
 
    if (project->suspended_via_gui) {
259
 
        pFrame->UpdateStatusText(_("Resuming project..."));
260
 
        pDoc->ProjectResume(strProjectName);
261
 
        pFrame->UpdateStatusText(wxT(""));
262
 
    } else {
263
 
        pFrame->UpdateStatusText(_("Suspending project..."));
264
 
        pDoc->ProjectSuspend(strProjectName);
265
 
        pFrame->UpdateStatusText(wxT(""));
 
266
    wxArrayInt arrSelRows = m_pGridPane->GetSelectedRows2();    
 
267
    n = (int)arrSelRows.GetCount();
 
268
    for(i=0; i<n; i++) {
 
269
        strProjectURL = 
 
270
            HtmlEntityEncode(
 
271
                m_pGridPane->GetCellValue(
 
272
                    arrSelRows[i],
 
273
                    COLUMN_HIDDEN_URL
 
274
                ).Trim(false)
 
275
            );
 
276
        PROJECT* project = pDoc->project(strProjectURL);
 
277
        
 
278
        if (project->suspended_via_gui) {
 
279
            pFrame->UpdateStatusText(_("Resuming project..."));
 
280
            pDoc->ProjectResume(strProjectURL);
 
281
        } else {
 
282
            pFrame->UpdateStatusText(_("Suspending project..."));
 
283
            pDoc->ProjectSuspend(strProjectURL);
 
284
        }
266
285
    }
 
286
    pFrame->UpdateStatusText(wxT(""));
267
287
        
268
288
    m_bForceUpdateSelection = true;
269
289
    UpdateSelection();
276
296
void CViewProjectsGrid::OnProjectNoNewWork( wxCommandEvent& WXUNUSED(event) ) {
277
297
    wxLogTrace(wxT("Function Start/End"), wxT("CViewProjectsGrid::OnProjectNoNewWork - Function Begin"));
278
298
 
279
 
    wxString        strProjectName = wxEmptyString;
 
299
    wxString        strProjectURL = wxEmptyString;
280
300
    CMainDocument*  pDoc           = wxGetApp().GetDocument();
281
301
    CAdvancedFrame* pFrame         = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
 
302
    int i, n;
282
303
 
283
304
    wxASSERT(pDoc);
284
305
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
286
307
    wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame));
287
308
    wxASSERT(m_pGridPane);
288
309
 
289
 
    strProjectName = 
290
 
        HtmlEntityEncode(
291
 
            m_pGridPane->GetCellValue(
292
 
                m_pGridPane->GetFirstSelectedRow(),
293
 
                COLUMN_PROJECT
294
 
            ).Trim(false)
295
 
        );
296
 
    PROJECT* project = pDoc->project(strProjectName);
 
310
    wxArrayInt arrSelRows = m_pGridPane->GetSelectedRows2();    
 
311
    n = (int)arrSelRows.GetCount();
 
312
    for(i=0; i<n; i++) {
 
313
        strProjectURL = 
 
314
            HtmlEntityEncode(
 
315
                m_pGridPane->GetCellValue(
 
316
                    arrSelRows[i],
 
317
                    COLUMN_HIDDEN_URL
 
318
                ).Trim(false)
 
319
            );
 
320
        PROJECT* project = pDoc->project(strProjectURL);
297
321
 
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(""));
302
 
    } else {
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);
 
325
        } else {
 
326
            pFrame->UpdateStatusText(_("Telling project to not fetch any additional tasks..."));
 
327
            pDoc->ProjectNoMoreWork(strProjectURL);
 
328
        }
306
329
    }
307
 
 
 
330
    pFrame->UpdateStatusText(wxT(""));
 
331
    
308
332
    m_bForceUpdateSelection = true;
309
333
    UpdateSelection();
310
334
    pFrame->FireRefreshView();
320
344
 
321
345
    wxInt32         iAnswer        = 0;
322
346
    wxString        strProjectName = wxEmptyString;
 
347
    wxString        strProjectURL  = wxEmptyString;
323
348
    wxString        strMessage     = wxEmptyString;
324
349
    CMainDocument*  pDoc           = wxGetApp().GetDocument();
325
350
    CAdvancedFrame* pFrame         = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
 
351
    int i, n;
326
352
 
327
353
    wxASSERT(pDoc);
328
354
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
335
361
 
336
362
    pFrame->UpdateStatusText(_("Resetting project..."));
337
363
 
338
 
    strProjectName = m_pGridPane->GetCellValue(m_pGridPane->GetFirstSelectedRow(), COLUMN_PROJECT);
339
 
 
340
 
    strMessage.Printf(
341
 
        _("Are you sure you want to reset project '%s'?"),
342
 
        strProjectName.c_str()    
343
 
    );
344
 
 
345
 
    iAnswer = ::wxMessageBox(
346
 
        strMessage,
347
 
        _("Reset Project"),
348
 
        wxYES_NO | wxICON_QUESTION,
349
 
        this
350
 
    );
351
 
 
352
 
    if (wxYES == iAnswer) {
353
 
        pDoc->ProjectReset(HtmlEntityEncode(strProjectName.Trim(false)));
 
364
    wxArrayInt arrSelRows = m_pGridPane->GetSelectedRows2();    
 
365
    n = (int)arrSelRows.GetCount();
 
366
    for(i=0; i<n; i++) {
 
367
        strProjectName = m_pGridPane->GetCellValue(arrSelRows[i], COLUMN_PROJECT);
 
368
        strProjectURL = m_pGridPane->GetCellValue(arrSelRows[i], COLUMN_HIDDEN_URL);
 
369
 
 
370
        strMessage.Printf(
 
371
            _("Are you sure you want to reset project '%s'?"),
 
372
            strProjectName.c_str()    
 
373
        );
 
374
 
 
375
        iAnswer = ::wxMessageBox(
 
376
            strMessage,
 
377
            _("Reset Project"),
 
378
            wxYES_NO | wxICON_QUESTION,
 
379
            this
 
380
        );
 
381
 
 
382
        if (wxYES == iAnswer) {
 
383
            pDoc->ProjectReset(HtmlEntityEncode(strProjectURL.Trim(false)));
 
384
        }
354
385
    }
355
 
 
 
386
    
356
387
    pFrame->UpdateStatusText(wxT(""));
357
388
 
358
389
    m_bForceUpdateSelection = true;
368
399
 
369
400
    wxInt32         iAnswer        = 0;
370
401
    wxString        strProjectName = wxEmptyString;
 
402
    wxString        strProjectURL  = wxEmptyString;
371
403
    wxString        strMessage     = wxEmptyString;
372
404
    CMainDocument*  pDoc           = wxGetApp().GetDocument();
373
405
    CAdvancedFrame* pFrame         = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame);
 
406
    int i, n;
374
407
 
375
408
    wxASSERT(pDoc);
376
409
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
383
416
 
384
417
    pFrame->UpdateStatusText(_("Detaching from project..."));
385
418
 
386
 
    strProjectName = m_pGridPane->GetCellValue(m_pGridPane->GetFirstSelectedRow(), COLUMN_PROJECT);
387
 
 
388
 
    strMessage.Printf(
389
 
        _("Are you sure you want to detach from project '%s'?"),
390
 
        strProjectName.c_str()
391
 
    );
392
 
 
393
 
    iAnswer = ::wxMessageBox(
394
 
        strMessage,
395
 
        _("Detach from Project"),
396
 
        wxYES_NO | wxICON_QUESTION,
397
 
        this
398
 
    );
399
 
 
400
 
    if (wxYES == iAnswer) {
401
 
        pDoc->ProjectDetach(HtmlEntityEncode(strProjectName.Trim(false)));
 
419
    wxArrayInt arrSelRows = m_pGridPane->GetSelectedRows2();    
 
420
    n = (int)arrSelRows.GetCount();
 
421
    for(i=0; i<n; i++) {
 
422
        strProjectName = m_pGridPane->GetCellValue(arrSelRows[i], COLUMN_PROJECT);
 
423
        strProjectURL = m_pGridPane->GetCellValue(arrSelRows[i], COLUMN_HIDDEN_URL);
 
424
 
 
425
        strMessage.Printf(
 
426
            _("Are you sure you want to detach from project '%s'?"),
 
427
            strProjectName.c_str()
 
428
        );
 
429
 
 
430
        iAnswer = ::wxMessageBox(
 
431
            strMessage,
 
432
            _("Detach from Project"),
 
433
            wxYES_NO | wxICON_QUESTION,
 
434
            this
 
435
        );
 
436
 
 
437
        if (wxYES == iAnswer) {
 
438
            pDoc->ProjectDetach(HtmlEntityEncode(strProjectURL.Trim(false)));
 
439
        }
402
440
    }
403
 
 
 
441
    
404
442
    pFrame->UpdateStatusText(wxT(""));
405
443
 
406
444
    m_bForceUpdateSelection = true;
440
478
    return wxGetApp().GetDocument()->GetProjectCount();
441
479
}
442
480
 
 
481
#if PREVENT_MULTIPLE_PROJECT_SELECTIONS
443
482
void CViewProjectsGrid::OnGridSelectRange( wxGridRangeSelectEvent& event ) {
444
483
    // Disallow multiple selections
445
484
    if (m_pGridPane->GetSelectedRows2().size() > 1) {
457
496
    m_pGridPane->ClearSelection();
458
497
    m_pGridPane->SelectRow(theRow);
459
498
}
460
 
 
 
499
#endif
461
500
 
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();
 
506
    int             i, n;
 
507
    bool            wasSuspended=false, wasNoNewWork=false;
 
508
    static int      lastCount = 0;
467
509
 
468
510
    wxASSERT(pDoc);
469
511
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
470
512
    wxASSERT(m_pTaskPane);
471
513
    wxASSERT(m_pGridPane);
472
514
 
473
 
        if(!m_bForceUpdateSelection) {
474
 
                return;
475
 
        }
 
515
    wxArrayInt arrSelRows = m_pGridPane->GetSelectedRows2();    
 
516
    n = (int)arrSelRows.GetCount();
 
517
 
 
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;
 
523
        lastCount = n;
 
524
    }
 
525
    
 
526
    if(!m_bForceUpdateSelection) {
 
527
        return;
 
528
    }
476
529
 
477
530
    CBOINCBaseView::PreUpdateSelection();
478
531
 
480
533
    // Update the tasks static box buttons
481
534
    //
482
535
    pGroup = m_TaskGroups[0];
 
536
    
 
537
    if (n > 0) {
 
538
        m_pTaskPane->EnableTaskGroupTasks(pGroup);
 
539
    } else {
 
540
        m_pTaskPane->DisableTaskGroupTasks(pGroup);
 
541
        UpdateWebsiteSelection(GRP_WEBSITES, NULL);
 
542
        if(m_TaskGroups.size()>1) {
 
543
            m_pTaskPane->DisableTaskGroupTasks(m_TaskGroups[1]);
 
544
        }
 
545
    }
 
546
   
 
547
    for(i=0; i<n; i++) {
 
548
        strProjectURL = HtmlEntityEncode(
 
549
            m_pGridPane->GetCellValue(arrSelRows[i],COLUMN_HIDDEN_URL).Trim(false)
 
550
        );
 
551
        project = pDoc->project(strProjectURL);
 
552
        if (!project) {
 
553
            m_pTaskPane->DisableTaskGroupTasks(pGroup);
 
554
            if(m_TaskGroups.size()>1) {
 
555
                m_pTaskPane->DisableTaskGroupTasks(m_TaskGroups[1]);
 
556
            }
 
557
            return;
 
558
        }
483
559
 
484
 
        if (m_pGridPane->GetSelectedRows2().size() == 1) {
485
 
        strProjectName = 
486
 
            HtmlEntityEncode(
487
 
                m_pGridPane->GetCellValue(
488
 
                    m_pGridPane->GetFirstSelectedRow(),
489
 
                    COLUMN_PROJECT
490
 
                ).Trim(false)
491
 
            );
492
 
        project = pDoc->project(strProjectName);
493
 
        m_pTaskPane->EnableTask(pGroup->m_Tasks[BTN_UPDATE]);
494
 
        m_pTaskPane->EnableTask(pGroup->m_Tasks[BTN_SUSPEND]);
495
 
        if (project) {
496
 
            if (project->suspended_via_gui) {
 
560
        if (i == 0) {
 
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.")
499
565
                );
502
568
                    pGroup->m_Tasks[BTN_SUSPEND], _("Suspend"), _("Suspend tasks for this project.")
503
569
                );
504
570
            }
 
571
        } else {
 
572
            if (wasSuspended != project->suspended_via_gui) {
 
573
                // Disable Suspend / Resume button if the multiple selection
 
574
                // has a mix of suspended and not suspended projects
 
575
                m_pTaskPane->DisableTask(pGroup->m_Tasks[BTN_SUSPEND]);
 
576
            }
505
577
        }
506
 
        m_pTaskPane->EnableTask(pGroup->m_Tasks[BTN_NOWORK]);
507
 
        if (project) {
 
578
 
 
579
        if (i == 0) {
 
580
            wasNoNewWork = project->dont_request_more_work;
508
581
            if (project->dont_request_more_work) {
509
582
                m_pTaskPane->UpdateTask(
510
583
                    pGroup->m_Tasks[BTN_NOWORK], _("Allow new tasks"), _("Allow fetching new tasks for this project.")
514
587
                    pGroup->m_Tasks[BTN_NOWORK], _("No new tasks"), _("Don't fetch new tasks for this project.")
515
588
                );
516
589
            }
 
590
        } else {
 
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]);
 
595
            }
517
596
        }
518
 
        m_pTaskPane->EnableTask(pGroup->m_Tasks[BTN_RESET]);
519
 
        if (project && project->attached_via_acct_mgr) {
 
597
        
 
598
        if (project->attached_via_acct_mgr) {
520
599
            m_pTaskPane->DisableTask(pGroup->m_Tasks[BTN_DETACH]);
 
600
        }
 
601
        
 
602
        if (n == 1) {
 
603
            UpdateWebsiteSelection(GRP_WEBSITES, project);
 
604
            if(m_TaskGroups.size()>1) {
 
605
                m_pTaskPane->EnableTaskGroupTasks(m_TaskGroups[1]);
 
606
            }
521
607
        } else {
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]);
 
611
            }
523
612
        }
524
 
 
525
 
        UpdateWebsiteSelection(GRP_WEBSITES, project);
526
 
 
527
 
    } else {
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]);
532
 
                }
533
613
    }
534
614
 
535
615
    CBOINCBaseView::PostUpdateSelection();
536
 
        m_bForceUpdateSelection=false;
 
616
 
 
617
    m_bForceUpdateSelection=false;
537
618
}
538
619
 
539
620
void CViewProjectsGrid::UpdateWebsiteSelection(long lControlGroup, PROJECT* project){
546
627
 
547
628
    // Update the websites list
548
629
    //
549
 
    if (m_TaskGroups.size() > 1) {
550
 
 
551
 
        // Delete task group, objects, and controls.
552
 
        pGroup = m_TaskGroups[lControlGroup];
553
 
 
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) {
 
632
 
 
633
            // Delete task group, objects, and controls.
 
634
            pGroup = m_TaskGroups[lControlGroup];
 
635
 
 
636
            m_pTaskPane->DeleteTaskGroupAndTasks(pGroup);
 
637
            for (i=0; i<pGroup->m_Tasks.size(); i++) {
 
638
                delete pGroup->m_Tasks[i];
 
639
            }
 
640
            pGroup->m_Tasks.clear();
 
641
            delete pGroup;
 
642
 
 
643
            pGroup = NULL;
 
644
 
 
645
            m_TaskGroups.erase( m_TaskGroups.begin() + 1 );
557
646
        }
558
 
        pGroup->m_Tasks.clear();
559
 
        delete pGroup;
560
 
 
561
 
        pGroup = NULL;
562
 
 
563
 
        m_TaskGroups.erase( m_TaskGroups.begin() + 1 );
564
 
    }
565
 
 
566
 
    // If something is selected create the tasks and controls
567
 
        if (m_pGridPane->GetSelectedRows2().size()==1) {
568
 
        if (project) {
569
 
            // Create the web sites task group
570
 
            pGroup = new CTaskItemGroup( _("Web sites") );
571
 
            m_TaskGroups.push_back( pGroup );
572
 
 
573
 
            // Default project url
574
 
            pItem = new CTaskItem(
575
 
                wxString(project->project_name.c_str(), wxConvUTF8),
576
 
                wxT(""),
577
 
                wxString(project->master_url.c_str(), wxConvUTF8),
578
 
                ID_TASK_PROJECT_WEB_PROJDEF_MIN
579
 
            );
580
 
            pGroup->m_Tasks.push_back(pItem);
581
 
 
582
 
 
583
 
            // Project defined urls
584
 
            for (i=0;(i<project->gui_urls.size())&&(i<=ID_TASK_PROJECT_WEB_PROJDEF_MAX);i++) {
 
647
 
 
648
        // If something is selected create the tasks and controls
 
649
        if (m_pGridPane->GetSelectedRows2().size() == 1) {
 
650
            if (project) {
 
651
                // Create the web sites task group
 
652
                pGroup = new CTaskItemGroup( _("Web sites") );
 
653
                m_TaskGroups.push_back( pGroup );
 
654
 
 
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),
 
658
                    wxT(""),
 
659
                    wxString(project->master_url.c_str(), wxConvUTF8),
 
660
                    ID_TASK_PROJECT_WEB_PROJDEF_MIN
590
661
                );
591
662
                pGroup->m_Tasks.push_back(pItem);
 
663
 
 
664
 
 
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
 
672
                    );
 
673
                    pGroup->m_Tasks.push_back(pItem);
 
674
                }
592
675
            }
593
676
        }
 
677
 
 
678
        m_bForceUpdateSelection = false;
594
679
    }
595
680
}
596
681
 
673
758
            append_to_status(strBuffer, _("Communication deferred ") + tsNextRPC.Format());
674
759
        }
675
760
    }
676
 
        if(wxEmptyString == strBuffer)
677
 
        {
678
 
                append_to_status(strBuffer, wxT("---"));
679
 
        }
 
761
    
 
762
    if(wxEmptyString == strBuffer) {
 
763
        append_to_status(strBuffer, wxT("---"));
 
764
    }
 
765
}
 
766
 
 
767
 
 
768
void CViewProjectsGrid::FormatProjectURL(wxInt32 item, wxString& strBuffer) {
 
769
    PROJECT* project = wxGetApp().GetDocument()->project(item);
 
770
    if (project) {
 
771
         strBuffer = wxString(project->master_url.c_str(), wxConvUTF8);
 
772
    }
680
773
}
681
774
 
682
775
 
771
864
    if(docCount != m_pGridPane->GetNumberRows()) {
772
865
        if (docCount > m_pGridPane->GetNumberRows()) {
773
866
            m_pGridPane->AppendRows(docCount - m_pGridPane->GetNumberRows());
774
 
        } else {
775
 
                    m_pGridPane->DeleteRows(0, m_pGridPane->GetNumberRows() - docCount);
 
867
         } else {
 
868
            m_pGridPane->DeleteRows(0, m_pGridPane->GetNumberRows() - docCount);
 
869
            m_bForceUpdateSelection = true;
776
870
        }
777
871
        wxASSERT(docCount == m_pGridPane->GetNumberRows());
778
872
    }
779
873
 
780
 
        wxString strBuffer;
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;
 
877
 
 
878
    wxString strBuffer;
 
879
    int iMax = m_pGridPane->GetNumberRows();
 
880
    for(int iRow = 0; iRow < iMax; iRow++) {
783
881
                
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);
787
885
        }
788
886
 
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);
792
890
        }
793
891
 
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);
797
895
        }
798
896
 
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);
802
900
        }
803
901
 
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);
807
905
        }
808
906
 
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);
813
 
        }
 
909
            m_pGridPane->SetCellValue(iRow, COLUMN_RESOURCESHARE, strBuffer);
 
910
            m_pGridPane->SetCellAlignment(iRow, COLUMN_RESOURCESHARE, wxALIGN_CENTRE, wxALIGN_CENTRE);
 
911
    }
814
912
 
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);
 
917
        }
 
918
 
 
919
        FormatProjectURL(iRow, strBuffer);
 
920
        if (m_pGridPane->GetCellValue(iRow, COLUMN_HIDDEN_URL) != strBuffer) {
 
921
            m_pGridPane->SetCellValue(iRow, COLUMN_HIDDEN_URL, strBuffer);
819
922
        }
820
923
    }
821
924
 
822
925
    m_pGridPane->SortData();
823
926
 
824
 
        UpdateSelection();
 
927
    m_bIgnoreUIEvents = true;
 
928
    m_pGridPane->RestoreSelection();
 
929
    m_bIgnoreUIEvents = false;
 
930
 
 
931
    UpdateSelection();
825
932
 
826
933
    wxLogTrace(wxT("Function Start/End"), wxT("CViewProjectsGrid::OnListRender - Function End"));
827
934
}