ProjectStatusListViewItemAdaptor.cs :  » Build-Systems » CruiseControl.NET » ThoughtWorks » CruiseControl » CCTrayLib » Presentation » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Build Systems » CruiseControl.NET 
CruiseControl.NET » ThoughtWorks » CruiseControl » CCTrayLib » Presentation » ProjectStatusListViewItemAdaptor.cs
using System;
using System.Windows.Forms;
using ThoughtWorks.CruiseControl.CCTrayLib.Configuration;
using ThoughtWorks.CruiseControl.CCTrayLib.Monitoring;

namespace ThoughtWorks.CruiseControl.CCTrayLib.Presentation{
  public class ProjectStatusListViewItemAdaptor
  {
    private readonly IDetailStringProvider detailStringProvider;
    private readonly ListViewItem item = new ListViewItem();
    private readonly ListViewItem.ListViewSubItem activity;
    private readonly ListViewItem.ListViewSubItem detail;
    private readonly ListViewItem.ListViewSubItem lastBuildLabel;
    private readonly ListViewItem.ListViewSubItem lastBuildTime;
    private readonly ListViewItem.ListViewSubItem projectStatus;
        private readonly ListViewItem.ListViewSubItem serverName;
        private readonly ListViewItem.ListViewSubItem category;
        private readonly ICCTrayMultiConfiguration config = null;
    
    public ProjectStatusListViewItemAdaptor(IDetailStringProvider detailStringProvider, ICCTrayMultiConfiguration config) : this(detailStringProvider)
    {
      this.config = config;  
    }

    public ProjectStatusListViewItemAdaptor(IDetailStringProvider detailStringProvider)
    {
      this.detailStringProvider = detailStringProvider;
      serverName = new ListViewItem.ListViewSubItem();
      item.SubItems.Add(serverName);
            category = new ListViewItem.ListViewSubItem(item, string.Empty);
            item.SubItems.Add(category);
            activity = new ListViewItem.ListViewSubItem(item, string.Empty);
      item.SubItems.Add(activity);
      detail = new ListViewItem.ListViewSubItem(item, string.Empty);
      item.SubItems.Add(detail);
      lastBuildLabel = new ListViewItem.ListViewSubItem(item, string.Empty);
      item.SubItems.Add(lastBuildLabel);
      lastBuildTime = new ListViewItem.ListViewSubItem(item, string.Empty);
      item.SubItems.Add(lastBuildTime);
            projectStatus = new ListViewItem.ListViewSubItem(item, string.Empty);
            item.SubItems.Add(projectStatus);
        }

    public ListViewItem Create(IProjectMonitor projectMonitor)
    {
      projectMonitor.Polled += new MonitorPolledEventHandler(Monitor_Polled);

      item.Text = projectMonitor.Detail.ProjectName;

      DisplayProjectStateInListViewItem(projectMonitor);

      return item;
    }

    private void Monitor_Polled(object sauce, MonitorPolledEventArgs args)
    {
      DisplayProjectStateInListViewItem(args.ProjectMonitor);
    }

    private void DisplayProjectStateInListViewItem(IProjectMonitor monitor)
    {
      item.ImageIndex = monitor.ProjectState.ImageIndex;

            if (monitor.Detail.IsConnected)
            {
        if (config != null)
        {
          foreach(CCTrayProject project in config.Projects)
          {
            if ((project.ProjectName == monitor.Detail.ProjectName)
              // add by rei , fixes issue with displaying wrong server in cctray, while multiple configured server 
              // having project with the same project name 
              && (project.BuildServer.DisplayName == monitor.Detail.Configuration.BuildServer.DisplayName))
            {
              serverName.Text = project.BuildServer.DisplayName;
            }
          }
        }
        else
        {
          serverName.Text = new Uri(monitor.Detail.WebURL).Host;
        }
        lastBuildLabel.Text = monitor.Detail.LastBuildLabel;
        lastBuildTime.Text = monitor.Detail.LastBuildTime.ToString();
        projectStatus.Text = monitor.ProjectIntegratorState;
        activity.Text = monitor.Detail.Activity.ToString();
                category.Text = monitor.Detail.Category;
      }
      else
      {
        activity.Text = lastBuildLabel.Text = string.Empty;
      }

      detail.Text = detailStringProvider.FormatDetailString(monitor.Detail);
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.