/// <summary> /// An implementation-helper for the <see cref="Drop"/> method that handles d'n'd in the Resource thread. /// </summary> protected static void ResourcesDroppedImpl(IResource resTarget, IResourceList resDropped) { // Separate the special case — new task creation by dropping on the root bool bNoTasks = true; foreach (string sResType in resDropped.GetAllTypes()) { bNoTasks = bNoTasks && (sResType != "Task"); } if ((bNoTasks) && (resTarget == Core.ResourceTreeManager.GetRootForType("Task"))) { // Create a new task from the root-dropped (or empty-space-dropped) attachments Core.UserInterfaceAP.QueueJob(JobPriority.Immediate, "New Task from Dropped Attachments", new ExecuteActionDelegate(new NewTaskAction().Execute), new ActionContext(resDropped)); } else if (bNoTasks) { // Dropping attachments on a normal task AddDescendants(resTarget, resDropped, _linkTarget); } else { // Moving the tasks along the tree, change the parent AddDescendants(resTarget, resDropped, _linkSuperTask); /* * foreach(IResource res in resDropped) * { * res.SetProp(TasksPlugin._linkTarget, resTarget); * Core.WorkspaceManager.AddToActiveWorkspace(res); * Core.WorkspaceManager.CleanWorkspaceLinks(res); * } */ } }
private IResourceList GetResourcesFromContext(IActionContext context) { IResourceList resources = context.SelectedResources; string[] resTypes = resources.GetAllTypes(); if (resTypes.Length > 0) { bool haveWrongTypes = false; for (int i = 0; i < resTypes.Length; i++) { if (Array.IndexOf(_resTypes, resTypes [i]) < 0) { haveWrongTypes = true; break; } } if (!haveWrongTypes) { return(resources); } } if (context.ListOwnerResource != null && Array.IndexOf(_resTypes, context.ListOwnerResource.Type) >= 0) { return(context.ListOwnerResource.ToResourceList()); } return(null); }
internal ResourceListState ConfigureColumns(ResourceListState state, IResourceList resList, IResource ownerResource) { RestoreSettings(); _displayColumnManager = Core.DisplayColumnManager as DisplayColumnManager; _resourceList = resList; _allTypes = _resourceList.GetAllTypes(); _allNoFileTypes = _displayColumnManager.CollapseFileTypes(_allTypes); _availableColumns = _displayColumnManager.GetAvailableColumns(_resourceList); _state = state; FillPropertyList(); SetViewRadioButtons(_state, ownerResource); if (ShowDialog(Core.MainWindow) == DialogResult.OK) { if (_state.KeyTypes != null && radThisView.Checked) { _state = new ResourceListState(new ColumnDescriptor[] {}, _state.SortSettings, state.GroupItems); _state.SetOwner(ownerResource, Core.TabManager.CurrentTabId); } else if (_state.OwnerResource != null && radAllViews.Checked) { _state.Delete(); _state = _displayColumnManager.StateFromList(_resourceList, _displayColumnManager.GetDefaultColumns(_resourceList), true); } SaveColumnsToState(_state); } return(_state); }
private void HandleItemDrag(object sender, ItemDragEventArgs e) { if (!_allowDrag) { return; } DataObject dataObj = new DataObject(); IResourceList selectedResources = GetSelectedResources(); dataObj.SetData(typeof(IResourceList), selectedResources); dataObj.SetData(typeof(ResourceListView2), this); string[] dragResTypes = selectedResources.GetAllTypes(); if (dragResTypes.Length == 1) { IResourceDragDropHandler handler = Core.PluginLoader.GetResourceDragDropHandler(selectedResources[0]); if (handler != null) { handler.AddResourceDragData(selectedResources, dataObj); } } DoDragDrop(dataObj, DragDropEffects.All | DragDropEffects.Move | DragDropEffects.Link); }
/// <summary> /// Locates and, if necessary, creates a resource list state which applies to all views /// with resources of types matching the contents of the resource list. /// </summary> internal ResourceListState StateFromList(IResourceList resList, ColumnDescriptor[] defaultColumns, bool defaultGroupItems) { string[] keyTypes = resList.GetAllTypes(); keyTypes = CollapseFileTypes(keyTypes); ComparableArrayList keyTypeList = new ComparableArrayList(keyTypes); ResourceListState state = (ResourceListState)_columnState [keyTypeList]; if (state == null) { IResource stateResource = Core.ResourceStore.FindUniqueResource("ColumnScheme", _props.ColumnKeyTypes, String.Join(";", keyTypes)); if (stateResource != null) { state = ResourceListState.FromResource(stateResource); // filter out invalid data if (state.Columns.Length == 0) { state.Columns = defaultColumns; } } else { state = new ResourceListState(defaultColumns, null, defaultGroupItems); state.KeyTypes = keyTypes; } _columnState [keyTypeList] = state; } return(state); }
/** * Returns the list of columns for the specified resource list. */ public ColumnDescriptor[] GetDefaultColumns(IResourceList resList) { if (resList == null) { throw new ArgumentNullException("resList"); } return(GetColumnsForTypes(resList.GetAllTypes())); }
public bool CanDropResources(IResource targetResource, IResourceList dragResources) { if (dragResources.Count > 0) { if (targetResource != _bookmarkService.BookmarksRoot) { if (targetResource.Type != "Folder") { return(false); } IBookmarkProfile targetProfile = _bookmarkService.GetOwnerProfile(targetResource); foreach (IResource dragRes in dragResources) { string error; IBookmarkProfile sourceProfile = _bookmarkService.GetOwnerProfile(dragRes); if (sourceProfile == targetProfile) { if (targetProfile != null && !targetProfile.CanMove(dragRes, targetResource, out error)) { return(false); } } else { if (sourceProfile != null && !sourceProfile.CanDelete(dragRes, out error)) { return(false); } if (targetProfile != null && !targetProfile.CanCreate(dragRes, out error)) { return(false); } } } IResource temp = targetResource; do { if (dragResources.IndexOf(temp) >= 0) { return(false); } temp = BookmarkService.GetParent(temp); } while(temp != null); } string[] types = dragResources.GetAllTypes(); if (types.Length < 3) { return((types[0] == "Weblink" || types[0] == "Folder") && (types.Length == 1 || types[1] == "Weblink" || types[1] == "Folder")); } } return(false); }
/** * Returns the list of available columns for the specified resource list. */ public IntArrayList GetAvailableColumns(IResourceList resList) { IntArrayList result = new IntArrayList(); GetAvailableColumnsFromList(result, (ArrayList)_availableColumns [""]); foreach (string type in resList.GetAllTypes()) { GetAvailableColumnsFromList(result, (ArrayList)_availableColumns [type]); } GetAvailableColumnsFromList(result, _allTypeColumns); return(result); }
public IResourceList SelectResourcesFromList(IWin32Window ownerWindow, IResourceList fromList, string dialogCaption, string helpTopic, IResourceList initialSelection) { string selectorType = InitDialog(dialogCaption, fromList.GetAllTypes(), null, helpTopic); _selectPane.SelectResources(new string[] { selectorType }, fromList, initialSelection); if (ShowDialog(ownerWindow) != DialogResult.OK) { return(null); } return(_selectPane.GetSelection()); }
private bool CheckResourceTypes(ActionComponent component, IResourceList selectedResources, ref string[] resTypes) { if (component.ResourceType != null) { if (resTypes == null) { resTypes = (selectedResources == null) ? new string[] {} : selectedResources.GetAllTypes(); } if (resTypes.Length != 1 || resTypes [0] != component.ResourceType) { return(false); } } return(true); }
internal void PrepareData(IWin32Window ownerWindow, IResourceList resList) { CategoryManager mgr = Core.CategoryManager as CategoryManager; _resList = resList; _propCategory = mgr.PropCategory; RestoreSettings(); _contentTypes = resList.GetAllTypes(); _contentTypeFilter = new ContentTypeFilter(); _contentTypeFilter.SetFilter(_contentTypes, -1); _categoryTree.AddNodeFilter(_contentTypeFilter); _categoryTree.AddNodeFilter(new CategoryNodeFilter()); _categoryTree.ThreeStateCheckboxes = true; _categoryTree.ParentProperty = Core.Props.Parent; _categoryTree.OpenProperty = mgr.PropCategoryExpanded; _categoryTree.RootResource = Core.ResourceTreeManager.ResourceTreeRoot; _categoryTree.ShowContextMenu = false; if (resList.Count == 1) { _lblResource.Resource = resList [0]; } else { _lblCategoriesFor.Text = "Categories for " + resList.Count + " resources:"; _lblResource.Visible = false; } if (_categoryTree.SelectedNode == null && _categoryTree.Nodes.Count > 0) { _categoryTree.SelectedNode = _categoryTree.Nodes [0]; } UpdateButtonState(); _categoryTree.Focus(); }
public void Execute(IActionContext context) { IResourceList resourcesToDelete = null; IResourceList selResources = context.SelectedResourcesExpanded; string[] selTypes = selResources.GetAllTypes(); IResourceStore store = Core.ResourceStore; IResourceList allDeleted = store.FindResourcesWithProp(null, Core.Props.IsDeleted); bool shiftPressed = Control.ModifierKeys == Keys.Shift; foreach (string resType in selTypes) { IResourceList typedResources = selResources.Intersect(store.GetAllResources(resType)); IResourceList deletedTypedResources; bool deletePermanent = shiftPressed; if (deletePermanent || ResourceDeleterOptions.GetDeleteAlwaysPermanently(resType)) { deletedTypedResources = typedResources; typedResources = store.EmptyResourceList; deletePermanent = true; } else { deletedTypedResources = typedResources.Intersect(allDeleted); typedResources = typedResources.Minus(deletedTypedResources); } IResourceDeleter deleter = Core.PluginLoader.GetResourceDeleter(resType); DialogResult result = DialogResult.No; if (typedResources.Count > 0) { if (!ResourceDeleterOptions.GetConfirmDeleteToRecycleBin(resType)) { result = DialogResult.Yes; } else { result = deleter.ConfirmDeleteResources(typedResources, deletePermanent, (selTypes.Length > 1)); } if (result == DialogResult.Cancel) { return; } if (result == DialogResult.Yes) { resourcesToDelete = typedResources.Union(resourcesToDelete); } } if (deletedTypedResources.Count > 0) { if (!ResourceDeleterOptions.GetConfirmDeletePermanently(resType)) { result = DialogResult.Yes; } else { result = deleter.ConfirmDeleteResources(deletedTypedResources, true, (selTypes.Length > 1)); } if (result == DialogResult.Cancel) { return; } if (result == DialogResult.Yes) { resourcesToDelete = deletedTypedResources.Union(resourcesToDelete); } } } if (resourcesToDelete != null) { Core.ResourceAP.QueueJob(JobPriority.Immediate, "Deleting resources", new ResourceListDelegate(DoDelete), resourcesToDelete); } }