void ResourceTree_OnRelease(ResourceTreeView.State state)
        {
            ReleaseResourceJob.UpdateUIDelegate actUpdateUI = ReleaseResourceCallback;

            _workMaster.AddJob(new JobArgs()
            {
                CouchDB = _couchdb,
                ErrorManager = ErrorManager,
                FileSystem = FileSystem,
                JobType = Master.JobType.ReleaseResource,
                RequestingUser = TEMP_USERNAME,
                Requestor = this,
                Resource = state.Resource,
                Timeout = 10000,
                UpdateUICallback = actUpdateUI
            });
        }
        void ResourceTree_OnCancel(ResourceTreeView.State state)
        {
            Common.Storage.Version resource = null;
            
            // If the resource of the state exists then cancel it
            // This happens when a translation is not required - non CreateResourceJob
            if ((resource = ResourceTree.GetResourceFromTree(state.Resource.Guid)) != null)
            {
                _workMaster.CancelJobForResource(resource);
                return;
            }

            if (IdTranslation.ContainsValue(state.Resource.Guid))
            {
                Guid oldGuid = Guid.Empty;

                lock (IdTranslation)
                {
                    Dictionary<Guid, Guid>.Enumerator en = IdTranslation.GetEnumerator();
                    while (en.MoveNext())
                    {
                        if (en.Current.Value == state.Resource.Guid)
                        {
                            oldGuid = en.Current.Key;
                            break;
                        }
                    }
                }

                resource = ResourceTree.GetResourceFromTree(oldGuid);
                _workMaster.CancelJobForResource(resource);
                return;
            }

            throw new InvalidOperationException("Could not locate resource.");
        }
        void ResourceTree_OnReload(ResourceTreeView.State state)
        {
            CheckUpdateStatusJob.UpdateUIDelegate actUpdateUI = null;
            
            switch(state.JobType)
            {
                case Master.JobType.CheckoutJob:
                    actUpdateUI = GetResourceCallback;
                    break;
                case Master.JobType.CheckUpdateStatus:
                    actUpdateUI = CheckUpdateStatus;
                    break;
                case Master.JobType.CreateResource:
                    // TODO
                    // This needs to delete the resource from CouchDB and then
                    // create the resource on CouchDB again.
                    throw new NotImplementedException();
                    break;
                case Master.JobType.GetResource:
                    actUpdateUI = GetResourceCallback;
                    break;
                case Master.JobType.ReleaseResource:
                    actUpdateUI = ReleaseResourceCallback;
                    break;
                case Master.JobType.SaveResource:
                    actUpdateUI = SaveResourceCallback;
                    break;
                default:
                    throw new InvalidOperationException("Unknown job type to retry.");
            }

            _workMaster.AddJob(new JobArgs()
            {
                CouchDB = _couchdb,
                ErrorManager = ErrorManager,
                FileSystem = FileSystem,
                JobType = state.JobType,
                RequestingUser = TEMP_USERNAME,
                Requestor = this,
                Resource = state.Resource,
                Timeout = (uint)Settings.Instance.NetworkTimeout,
                UpdateUICallback = actUpdateUI
            });
        }
        void ResourceTree_OnItemSelect(ResourceTreeView.State state)
        {
            if (state == null)
            {
                BtnOpenSelected.IsEnabled = BtnSaveSelected.IsEnabled = BtnGetSelected.IsEnabled = false;
                _statusBarItemGuid = Guid.Empty;
                SBItem.Content = "";
                return;
            }

            _statusBarItemGuid = state.Resource.Guid;


            // Outdated Brush = Local resource is outdated (older than remote)
            // Error Brush = Something bad happened and the last action failed
            // Need Updated Brush = Local resource is newer than remote and needs saved to the server
            // Normal Brush = Local matches remote

            /* if outdated -> disable save, enable get
             * else if error...
             * We ran into a problem, if error, what was the previous state???
             * Need to implement a new state tracking class.
             */

            if (state.IsLocalOlder)
            {
                BtnSaveSelected.IsEnabled = false;
                BtnGetSelected.IsEnabled = true;
            }
            else if (state.IsLocalNewer)
            {
                BtnSaveSelected.IsEnabled = true;
                BtnGetSelected.IsEnabled = false;
            }
            else if (state.IsLocalSameAsRemote)
            {
                BtnSaveSelected.IsEnabled = false;
                BtnGetSelected.IsEnabled = false;
            }
            else
                throw new Exception("Unknown state");
        }
 void ResourceTree_OnStatusUpdate(ResourceTreeView.State state, string status)
 {
     if (state.Resource.Guid == _statusBarItemGuid)
         SBItem.Content = status;
 }