Exemplo n.º 1
0
        /// <summary>
        /// Adds a shortcut to the specified resource to the shortcut bar.
        /// </summary>
        public void AddShortcutToResource(IResource newShortcut)
        {
            ITabManager tabManager      = Core.TabManager;
            IResource   activeWorkspace = Core.WorkspaceManager.ActiveWorkspace;

            IResourceList shortcutTargets = newShortcut.GetLinksOfType("Shortcut", ShortcutProps.Target);

            if (newShortcut.Type == "SearchView")
            {
                foreach (IResource res in shortcutTargets)
                {
                    if (res.GetStringProp(ShortcutProps.TabID) == tabManager.CurrentTabId &&
                        res.GetLinkProp(ShortcutProps.Workspace) == activeWorkspace)
                    {
                        return;
                    }
                }
            }
            else
            {
                if (shortcutTargets.Count > 0)
                {
                    return;
                }
            }

            ResourceProxy proxy = ResourceProxy.BeginNewResource("Shortcut");

            proxy.SetProp(ShortcutProps.Order, _maxOrder + 1);
            proxy.AddLink(ShortcutProps.Target, newShortcut);

            if (activeWorkspace != null)
            {
                proxy.AddLink(ShortcutProps.Workspace, activeWorkspace);
            }

            if (newShortcut.Type == "SearchView")
            {
                proxy.SetProp(ShortcutProps.TabID, tabManager.CurrentTabId);
                string wsName = "";
                if (activeWorkspace != null)
                {
                    wsName = " in " + activeWorkspace.GetStringProp(Core.Props.Name);
                }

                proxy.SetProp(Core.Props.Name, tabManager.CurrentTab.Name + wsName + ": " +
                              newShortcut.DisplayName);
            }
            else if (newShortcut.DisplayName.Length > 20)
            {
                proxy.SetProp(Core.Props.Name, newShortcut.DisplayName.Substring(0, 20) + "...");
            }
            proxy.EndUpdate();
            RebuildShortcutBar();
        }
Exemplo n.º 2
0
        public void LinkToResourceRoot(IResource res, int index)
        {
            // First, set the user-sort-order, if appropriate, so that there were no jumping of the item after it's added
            if (index == int.MinValue)
            {
                new UserResourceOrder(res, JobPriority.Immediate).Insert(0, new int[] { res.OriginalId }, false, null);                 // To the beginning
            }
            else if (index == int.MaxValue)
            {
                new UserResourceOrder(res, JobPriority.Immediate).Insert(0, new int[] { res.OriginalId }, true, null);                  // To the end
            }
            else if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index", "The index must be a non-negative integer value, int.MinValue, or int.MaxValue.");
            }

            // Insert the resource
            IResource rootResource = GetRootForType(_resTreeRoot);

            if (res.GetLinkProp(Core.Props.Parent) != rootResource || res.GetIntProp("RootSortOrder") != index)
            {
                ResourceProxy proxy = new ResourceProxy(res);
                proxy.BeginUpdate();
                if (rootResource != null)
                {
                    proxy.AddLink(Core.Props.Parent, rootResource);
                }
                proxy.SetProp("RootSortOrder", index);
                proxy.EndUpdate();
            }
        }
Exemplo n.º 3
0
        private void DoAddRepository(object sender, EventArgs e)
        {
            string   repTypeId  = null;
            MenuItem senderItem = (MenuItem)sender;

            foreach (RepositoryType repType in SccPlugin.RepositoryTypes)
            {
                if (repType.Name == senderItem.Text)
                {
                    repTypeId = repType.Id;
                    break;
                }
            }
            if (repTypeId == null)
            {
                return;
            }

            ResourceProxy proxy = ResourceProxy.BeginNewResource(Props.RepositoryResource);

            proxy.SetProp(Core.Props.Name, "<unnamed>");
            proxy.SetProp(Props.RepositoryType, repTypeId);
            proxy.AddLink(Core.Props.Parent, Core.ResourceTreeManager.GetRootForType(Props.RepositoryResource));
            proxy.EndUpdate();

            SccPlugin.GetRepositoryType(repTypeId).EditRepository(this, proxy.Resource);

            RefreshRepositoryList(proxy.Resource);
        }
Exemplo n.º 4
0
        public void  Exec(IResource res, IActionParameterStore actionStore)
        {
            IResourceList categories = actionStore.ParametersAsResList();
            IResourceList authors    = res.GetLinksOfType(null, Core.ContactManager.Props.LinkFrom);

            foreach (IResource author in authors)
            {
                IResourceType type = Core.ResourceStore.ResourceTypes[author.TypeId];

                //  Do not assign categories for resource types which are
                //  internal in the sence - they are not showable in the
                //  traditional ResourceListView pane. Thus, user can not
                //  benefit from setting a category to these internal types.

                if (!type.HasFlag(ResourceTypeFlags.Internal))
                {
                    ResourceProxy proxy = new ResourceProxy(author);
                    proxy.BeginUpdate();
                    foreach (IResource category in categories)
                    {
                        proxy.AddLink("Category", category);
                    }

                    proxy.EndUpdate();
                }
            }
        }
Exemplo n.º 5
0
        private TResourceObject CreateNewResource(TJira itemJira)
        {
            ResourceProxy proxy = ResourceProxy.BeginNewResource(_restype);

            proxy.SetProp(Props.JiraId, itemJira.id);
            proxy.AddLink(Core.Props.Parent, _server.Resource);

            proxy.EndUpdate();

            return(CreateResourceObject(proxy.Resource));
        }
Exemplo n.º 6
0
        private static void ProcessFileChanges(IResource repository, ResourceProxy csProxy, XmlElement node, int revision)
        {
            foreach (XmlElement pathNode in node.SelectNodes("paths/path"))
            {
                string action = pathNode.GetAttribute("action");
                string path   = pathNode.InnerText;

                int    pos        = path.LastIndexOf('/');
                string folderName = path.Substring(0, pos);
                string fileName   = path.Substring(pos + 1);

                IResource folder = FindOrCreateFolder(repository, folderName);
                csProxy.AddLink(Props.AffectsFolder, folder);

                FileChange fileChange = FileChange.Create();
                fileChange.Name          = fileName;
                fileChange.AffectsFolder = folder;
                switch (action)
                {
                case "A":
                    fileChange.ChangeType = "add";
                    break;

                case "D":
                    fileChange.ChangeType = "delete";
                    break;

                case "R":
                    fileChange.ChangeType = "replace";
                    break;

                default:
                    fileChange.ChangeType = "change";
                    break;
                }
                fileChange.Revision = revision;
                fileChange.Save();

                csProxy.AddLink(Props.Change, fileChange.Resource);
            }
        }
Exemplo n.º 7
0
        public static void MergeABs(IResource dest, IResource src)
        {
            ResourceProxy prxDest  = new ResourceProxy(dest);
            IResourceList contacts = src.GetLinksOfType("Contact", _propInAddressBook);

            foreach (IResource contact in contacts)
            {
                prxDest.AddLink(_propInAddressBook, contact);
            }
            ResourceProxy prxSrc = new ResourceProxy(src);

            prxSrc.Delete();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Creates a new JIRA server resource.
        /// </summary>
        public static JiraServer CreateNew()
        {
            ResourceProxy proxy = ResourceProxy.BeginNewResource(Type);

            proxy.AddLink(Core.Props.Parent, RootResource);
            proxy.EndUpdate();

            JiraServer retval = new JiraServer(proxy.Resource);

            retval.Name = Jiffa.GetRandomName();

            return(retval);
        }
Exemplo n.º 9
0
        /// <summary>
        /// While syncing to JIRA, creates a new Omea resource for the locally-missing project.
        /// </summary>
        /// <returns></returns>
        protected JiraProject CreateProject(RemoteProject projectJira)
        {
            ResourceProxy proxy = ResourceProxy.BeginNewResource(Types.JiraProject);

            proxy.AsyncPriority = JobPriority.Normal;

            proxy.SetProp(Props.JiraId, projectJira.id);
            proxy.AddLink(Core.Props.Parent, Resource);

            proxy.EndUpdate();

            return(GetProject(proxy.Resource));
        }
Exemplo n.º 10
0
        private JiraComponent CreateComponent(RemoteComponent componentJira)
        {
            ResourceProxy proxy = ResourceProxy.BeginNewResource(Types.JiraComponent);

            proxy.AsyncPriority = JobPriority.Normal;

            proxy.SetProp(Props.JiraId, componentJira.id);
            proxy.AddLink(Core.Props.Parent, Resource);

            proxy.EndUpdate();

            return(GetComponent(proxy.Resource));
        }
Exemplo n.º 11
0
        private static void SaveChangeSet(IResource repository, IResource changeSet, ChangeSetDetails details)
        {
            if (changeSet.HasProp(Props.Change))
            {
                return;
            }

            ResourceProxy proxy = new ResourceProxy(changeSet);

            proxy.BeginUpdate();

            SetChangeSetDescription(proxy, details.Description);

            foreach (var fileChangeData in details.FileChanges)
            {
                int    pos        = fileChangeData.Path.LastIndexOf('/');
                string folderName = fileChangeData.Path.Substring(0, pos);
                string fileName   = fileChangeData.Path.Substring(pos + 1);

                IResource folder = FindOrCreateFolder(repository, folderName);
                proxy.AddLink(Props.AffectsFolder, folder);

                var fileChange = FileChange.Create();
                fileChange.Name          = fileName;
                fileChange.AffectsFolder = folder;
                fileChange.ChangeType    = fileChangeData.ChangeType;
                fileChange.Revision      = fileChangeData.Revision;
                fileChange.Diff          = fileChangeData.Diff;
                fileChange.Binary        = fileChangeData.Binary;
                fileChange.Save();

                proxy.AddLink(Props.Change, fileChange.Resource);
            }

            proxy.EndUpdate();
            Core.TextIndexManager.QueryIndexing(proxy.Resource.Id);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Creates a workspace with the specified name.
        /// </summary>
        public IResource CreateWorkspace(string name)
        {
            ResourceProxy proxy = ResourceProxy.BeginNewResource(_props.WorkspaceResourceType);

            proxy.SetProp("Name", name);
            proxy.EndUpdate();

            ResourceProxy otherViewProxy = ResourceProxy.BeginNewResource("WorkspaceOtherView");

            otherViewProxy.SetProp("Name", "Other");
            otherViewProxy.AddLink(_props.InWorkspace, proxy.Resource);
            otherViewProxy.EndUpdate();

            _resourceTreeManager.SetResourceNodeSort(proxy.Resource, "Type Name");
            return(proxy.Resource);
        }
Exemplo n.º 13
0
        public void Save(IResource contact)
        {
            ResourceProxy proxy = new ResourceProxy(contact);

            proxy.BeginUpdate();
            try
            {
                proxy.AsyncPriority = JobPriority.Immediate;
                for (int i = 0; i < _emailsList.Items.Count; ++i)
                {
                    ListViewItem item    = _emailsList.Items[i];
                    IResource    account = (IResource)Core.ResourceAP.RunUniqueJob(
                        new FindOrCreateEmailAccountDelegate(Core.ContactManager.FindOrCreateEmailAccount), item.Text);
                    proxy.AddLink(Core.ContactManager.Props.LinkEmailAcct, account);
                    _originalAccounts.Remove(item.Text);
                    if (item.SubItems[1].Text == DefltMarker)
                    {
                        proxy.SetProp(ContactManager._propDefaultAccount, account);
                    }
                    new ResourceProxy(account).SetProp(Core.ContactManager.Props.PersonalAccount, _isStartupMode || item.Checked);
                }

                //  Delete links to those accounts which were originally
                //  connected to the contact and did not keep their place in
                //  the list (were removed or renamed).
                foreach (HashSet.Entry e in _originalAccounts)
                {
                    IResource accnt = Core.ResourceStore.FindUniqueResource(
                        "EmailAccount", Core.ContactManager.Props.EmailAddress, e.Key);
                    if (accnt != null)
                    {
                        Core.ResourceAP.RunUniqueJob(new SplitDelegate(HardRemoveAccountFromContact), accnt, contact);
                    }
                }
            }
            finally
            {
                proxy.EndUpdateAsync();
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Creates resources from the specified array of change set descriptors.
        /// </summary>
        /// <param name="changeSets">The change sets to be converted to resources.</param>
        private void CreateChangeSetResources(IResource repository, ChangeSetSummary[] changeSets)
        {
            string[] ignoredClients = repository.GetProp(Props.P4IgnoreChanges).Split(';');

            foreach (ChangeSetSummary changeSet in changeSets)
            {
                if (Array.IndexOf(ignoredClients, changeSet.Client) >= 0)
                {
                    continue;
                }

                if (FindChangeSet(repository, changeSet.Number) != null)
                {
                    continue;
                }

                ResourceProxy proxy = ResourceProxy.BeginNewResource(Props.ChangeSetResource);
                proxy.SetProp(Props.ChangeSetNumber, changeSet.Number);
                proxy.SetProp(Core.Props.Date, changeSet.Date);
                proxy.SetProp(Props.P4Client, changeSet.Client);
                proxy.SetProp(Core.Props.IsUnread, true);
                proxy.AddLink(Props.ChangeSetRepository, repository);
                proxy.EndUpdate();
                LinkChangeSetToContact(repository, proxy.Resource, changeSet.User);

                // Execute rules for the new changeset
                Core.FilterEngine.ExecRules(StandardEvents.ResourceReceived, proxy.Resource);

                // Request text indexing of the changeset
                Core.TextIndexManager.QueryIndexing(proxy.Resource.Id);

                if (changeSet.Number > repository.GetProp(Props.LastRevision))
                {
                    new ResourceProxy(repository).SetPropAsync(Props.LastRevision, changeSet.Number);
                }
            }
        }
Exemplo n.º 15
0
        private void ParseSvnLog(IResource repository, int startRevision, int lastRevision)
        {
            string log;

            try
            {
                log = GetRunner(repository).GetXmlLog(startRevision, lastRevision);
                ClearLastError(repository);
            }
            catch (RunnerException ex)
            {
                SetLastError(repository, ex);
                return;
            }
            XmlDocument doc = new XmlDocument();

            doc.Load(new StringReader(log));
            foreach (XmlElement node in doc.SelectNodes("//logentry"))
            {
                int revision = Int32.Parse(node.GetAttribute("revision"));
                if (FindChangeSet(repository, revision) != null)
                {
                    continue;
                }

                string   author = "", description = "";
                DateTime date      = DateTime.Now;
                XmlNode  childNode = node.SelectSingleNode("author");
                if (childNode != null)
                {
                    author = childNode.InnerText;
                }
                childNode = node.SelectSingleNode("msg");
                if (childNode != null)
                {
                    description = childNode.InnerText;
                }
                childNode = node.SelectSingleNode("date");
                if (childNode != null)
                {
                    date = DateTime.Parse(childNode.InnerText);
                }

                ResourceProxy proxy = ResourceProxy.BeginNewResource(Props.ChangeSetResource);
                proxy.SetProp(Props.ChangeSetNumber, revision);
                proxy.SetProp(Core.Props.Date, date);
                proxy.SetProp(Core.Props.IsUnread, true);
                SetChangeSetDescription(proxy, description);
                proxy.AddLink(Props.ChangeSetRepository, repository);
                ProcessFileChanges(repository, proxy, node, revision);
                proxy.EndUpdate();

                LinkChangeSetToContact(repository, proxy.Resource, author);

                // Execute rules for the new changeset
                Core.FilterEngine.ExecRules(StandardEvents.ResourceReceived, proxy.Resource);

                // Request text indexing of the changeset
                Core.TextIndexManager.QueryIndexing(proxy.Resource.Id);

                if (revision > repository.GetProp(Props.LastRevision))
                {
                    new ResourceProxy(repository).SetPropAsync(Props.LastRevision, revision);
                }
            }
        }