/** * Returns the necessary result for the situation when the resource changed * to match the predicate. It may have been already added to the snapshot * list, so the Match result instead of the Add result should be returned. */ protected PredicateMatch CheckSnapshotAdd(int resID) { if (_snapshot && _snapshotList != null) { if (_snapshotList.IndexOf(resID) >= 0) { return(PredicateMatch.Match); } } return(PredicateMatch.Add); }
[Test] public void TestRegisterAvailableColumn() { _displayColumnManager.RegisterAvailableColumn("Email", new ColumnDescriptor("Name", 100)); _displayColumnManager.RegisterAvailableColumn(null, new ColumnDescriptor("Received", 50)); _storage.NewResource("Email"); IResourceList emails = _storage.GetAllResources("Email"); IntArrayList propIds = _displayColumnManager.GetAvailableColumns(emails); Assert.AreEqual(2, propIds.Count); Assert.IsTrue(propIds.IndexOf(_storage.GetPropId("Name")) >= 0); Assert.IsTrue(propIds.IndexOf(_storage.GetPropId("Received")) >= 0); }
protected LinkSection BuildLinksForResource(IResource res) { IntArrayList linkTypes = new IntArrayList(res.GetLinkTypeIds()); linkTypes.Sort(); LinkSection lastSection = null; LinkSection groupStartSection; foreach (IntArrayList propIds in _linksPaneGroups) { groupStartSection = lastSection; foreach (int propId in propIds) { int idx = linkTypes.IndexOf(propId); if (idx >= 0) { lastSection = BuildLinksForType(lastSection, propId, res); linkTypes.RemoveAt(idx); } } if (groupStartSection != lastSection) { lastSection.Separator = true; } } groupStartSection = lastSection; foreach (int linkType in linkTypes) { if (_store.PropTypes [linkType].HasFlag(PropTypeFlags.Internal)) { continue; } lastSection = BuildLinksForType(lastSection, linkType, res); } if (lastSection != groupStartSection) { lastSection.Separator = true; } if (lastSection != null) { while (lastSection.PrevSection != null) { lastSection = lastSection.PrevSection; } } return(lastSection); }
public DragDropEffects DragOver(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState) { if (data.GetDataPresent(typeof(IResourceList))) { // The resources we're dragging IResourceList dragResources = (IResourceList)data.GetData(typeof(IResourceList)); // Currently, only the Deleted Resources view has a drop handler if (!FilterRegistry.IsDeletedResourcesView(targetResource)) { return(DragDropEffects.None); } // Collect all the direct and indirect parents of the droptarget; then we'll check to avoid dropping parent on its children IntArrayList parentList = IntArrayListPool.Alloc(); try { IResource parent = targetResource; while (parent != null) { parentList.Add(parent.Id); parent = parent.GetLinkProp(Core.Props.Parent); } // Check foreach (IResource res in dragResources) { // Dropping parent over its child? if (parentList.IndexOf(res.Id) >= 0) { return(DragDropEffects.None); } // Cannot delete resource containers this way if ((Core.ResourceStore.ResourceTypes[res.Type].Flags & ResourceTypeFlags.ResourceContainer) != 0) { return(DragDropEffects.None); // Cannot delete containers } } return(DragDropEffects.Move); } finally { IntArrayListPool.Dispose(parentList); } } else { return(DragDropEffects.None); } }
[Test] public void Insert() { IntArrayList list = new IntArrayList(); for (int i = 0; i < 256; i++) { list.Insert(0, i); } AssertEquals(256, list.Count); for (int i = 0; i < 256; i++) { AssertEquals(255 - i, list [i]); AssertEquals(i, list.IndexOf(255 - i)); } }
public DragDropEffects DragOver(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState) { if (data.GetDataPresent(typeof(IResourceList))) { // The resources we're dragging IResourceList dragResources = (IResourceList)data.GetData(typeof(IResourceList)); // Check if really dropping over a view-folder if (!(targetResource.Type == FilterManagerProps.ViewFolderResName)) { return(DragDropEffects.None); } // Collect all the direct and indirect parents of the droptarget; then we'll check to avoid dropping parent on its children IntArrayList parentList = IntArrayListPool.Alloc(); try { IResource parent = targetResource; while (parent != null) { parentList.Add(parent.Id); parent = parent.GetLinkProp(Core.Props.Parent); } // Check foreach (IResource res in dragResources) { // Dropping parent over its child? if (parentList.IndexOf(res.Id) >= 0) { return(DragDropEffects.None); } // Can drop only views and view-folders on view-folders if (!FilterRegistry.IsViewOrFolder(res)) { return(DragDropEffects.None); } } return(DragDropEffects.Move); } finally { IntArrayListPool.Dispose(parentList); } } return(DragDropEffects.None); }
/** * Returns the list of all link types for the given resource. If the resource * was changed, the list also includes the link types which were present on * the resource before the change. */ private IntArrayList GetAllLinkTypes(IResource res, IPropertyChangeSet cs) { IntArrayList linkTypeIDs = new IntArrayList(res.GetLinkTypeIds()); if (cs != null) { int[] changedPropIDs = cs.GetChangedProperties(); for (int i = 0; i < changedPropIDs.Length; i++) { int propID = changedPropIDs [i]; if (_store.PropTypes [propID].DataType == PropDataType.Link && linkTypeIDs.IndexOf(propID) < 0) { linkTypeIDs.Add(propID); } } } return(linkTypeIDs); }
public DragDropEffects DragOver(IResource targetResource, IDataObject data, DragDropEffects allowedEffect, int keyState) { if (data.GetDataPresent(typeof(IResourceList))) { // The resources we're dragging IResourceList dragResources = (IResourceList)data.GetData(typeof(IResourceList)); // Check the droptarget, it must be either a folder or a tree root if (!((targetResource.Type == "RSSFeedGroup") || (targetResource == Core.ResourceTreeManager.GetRootForType("RSSFeed")))) { return(DragDropEffects.None); } // Collect all the direct and indirect parents of the droptarget; then we'll check to avoid dropping parent on its children IntArrayList parentList = new IntArrayList(); IResource parent = targetResource; while (parent != null) { parentList.Add(parent.Id); parent = parent.GetLinkProp(Core.Props.Parent); } bool bAllDroppable = true; // Feeds or groups are being dragged foreach (IResource res in dragResources) { // Dropping parent over its child? if (parentList.IndexOf(res.Id) >= 0) { return(DragDropEffects.None); } // Constraint the resource types of the resources being dropped bAllDroppable = bAllDroppable && ((res.Type == "RSSFeed") || (res.Type == "RSSFeedGroup")); } return(bAllDroppable ? DragDropEffects.Move : DragDropEffects.None); } else if (data.GetDataPresent(CLIPBOARD_FORMAT_URL) || data.GetDataPresent(CLIPBOARD_FORMAT_URL_W)) { return(DragDropEffects.Copy); } return(DragDropEffects.None); }
public static void RegisterLinksGroup(string groupId, int[] propTypes, ListAnchor anchor) { IntArrayList existingList = (IntArrayList)_linksPaneGroups.FindByKey(groupId); if (existingList != null) { foreach (int propType in propTypes) { if (existingList.IndexOf(propType) < 0) { existingList.Add(propType); } } } else { _linksPaneGroups.Add(groupId, new IntArrayList(propTypes), anchor); } }
/** * Adds the property IDs of the available columns from the specified list to the * specified IntArrayList. */ private void GetAvailableColumnsFromList(IntArrayList outList, ArrayList columnList) { if (columnList == null) { return; } foreach (DisplayColumn col in columnList) { int[] propIDs = PropNamesToIDs(col.PropNames, true); for (int i = 0; i < propIDs.Length; i++) { if (outList.IndexOf(propIDs [i]) < 0) { outList.Add(propIDs [i]); } } } }
public void AddResourceList(IResourceList dropResList) { // check if any resources in _contents have been deleted (#4310) IntArrayList contentsList = new IntArrayList(_contents.ResourceIds); for (int i = 0; i < dropResList.Count; i++) { if (contentsList.IndexOf(dropResList.ResourceIds [i]) < 0) { contentsList.Add(dropResList.ResourceIds [i]); } } for (int i = contentsList.Count - 1; i >= 0; i--) { IResource content; try { content = Core.ResourceStore.LoadResource(contentsList [i]); } catch (StorageException) { contentsList.RemoveAt(i); continue; } if (content.IsTransient) { Core.ResourceAP.QueueJob(JobPriority.Immediate, new MethodInvoker(content.EndUpdate)); } } // we need a live list ClipboardContents = Core.ResourceStore.ListFromIds(contentsList, true); AutoGrow(); }
public override int IndexOf(int id) { return(_ids.IndexOf(id)); }
internal static string SubstituteName(IResource res, int propId) { #region Preconditions if (res == null) { throw new ArgumentNullException("ContactsPlugin -- Input resource is NULL on name substitution."); } #endregion Preconditions ContactManager mgr = Core.ContactManager as ContactManager; if (mgr.IsMajorLink(propId)) { IResourceList contacts = res.GetLinksOfType(null, propId); IntArrayList contactsIDs = new IntArrayList(contacts.ResourceIds); int linkNameId = mgr.GetNameLinkId(propId); IResourceList contactNames = res.GetLinksOfType("ContactName", linkNameId); string[] results = new string [contacts.Count]; // In case of any problems or mismatches in the link structure, // fall back to default processing if (contactNames.Count > contactsIDs.Count) { return(res.GetPropText(propId)); } for (int i = 0; i < contactNames.Count; i++) { IResource contactName = Core.ResourceStore.TryLoadResource(contactNames.ResourceIds [i]); if (contactName == null) { results [i] = ""; continue; } IResource contact = contactName.GetLinkProp("BaseContact"); if (contact == null) { return(res.GetPropText(propId)); } int index = contactsIDs.IndexOf(contact.Id); if (index < 0) { return(res.GetPropText(propId)); } contactsIDs.RemoveAt(index); if (contact.HasProp(Core.ContactManager.Props.ShowOriginalNames)) { results [i] = contactName.GetStringProp("Name"); } else { results [i] = contact.DisplayName; } } for (int i = 0; i < contactsIDs.Count; i++) { IResource majorLinkResource = Core.ResourceStore.TryLoadResource(contactsIDs [i]); if (majorLinkResource != null) { results [i + contactNames.Count] = majorLinkResource.DisplayName; } else { results [i + contactNames.Count] = ""; } } return(String.Join(", ", results)); } return(res.GetPropText(propId)); }
private static bool IsFeedExportable(IntArrayList feedsIds, IResource feed) { return((feedsIds == null) || (feedsIds.IndexOf(feed.Id) != -1)); }
internal override PredicateMatch MatchResource(IResource res, IPropertyChangeSet cs) { return((_resources.IndexOf(res.Id) >= 0) ? PredicateMatch.Match : PredicateMatch.None); }