private void cbRoles_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.cbRoles.SelectedValue == null) return; this.TridionFolder.TridionRole = (TridionRole)this.cbRoles.SelectedValue; this.TridionSelectorMode = TridionSelectorMode.Folder; this.treeTridionFolder.ItemsSource = Functions.GetPublications(this.CurrentMapping).Expand(this.CurrentMapping, this.TridionSelectorMode, this.TridionFolder.TcmIdPath, this.TridionFolder.TcmId).MakeExpandable(); }
private void cbRoles_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.cbRoles.SelectedValue == null) { return; } this.TridionFolder.TridionRole = (TridionRole)this.cbRoles.SelectedValue; this.TridionSelectorMode = TridionSelectorMode.Folder; this.treeTridionFolder.ItemsSource = MainService.GetPublications(this.CurrentMapping).Expand(this.CurrentMapping, this.TridionSelectorMode, this.TridionFolder.TcmIdPath, this.TridionFolder.TcmId).MakeExpandable(); }
private void lstTemplates_SelectionChanged(object sender, SelectionChangedEventArgs e) { ItemInfo template = this.lstTemplates.SelectedItem as ItemInfo; if (template == null) { return; } this.TestTemplateTcmId = template.TcmId; Common.IsolatedStorage.Service.SaveToIsolatedStorage(Common.IsolatedStorage.Service.GetId("DebugTemplate", this.TbbTcmId), this.TestTemplateTcmId); //set test components tree string strTcmIdPath = Common.IsolatedStorage.Service.GetFromIsolatedStorage(Common.IsolatedStorage.Service.GetId("DebugItemPath", this.TbbTcmId, this.TestTemplateTcmId)); List <string> tcmIdPath = string.IsNullOrEmpty(strTcmIdPath) ? null : strTcmIdPath.Split('|').ToList(); if (tcmIdPath == null && !string.IsNullOrEmpty(this.TestItemTcmId)) { tcmIdPath = MainService.GetIdPath(this.CurrentMapping, this.TestItemTcmId); } if (tcmIdPath != null && string.IsNullOrEmpty(this.TestItemTcmId)) { this.TestItemTcmId = tcmIdPath.First(); } //smart folder detect if (string.IsNullOrEmpty(this.TestItemTcmId)) { ComponentTemplateData templateData = MainService.ReadItem(this.CurrentMapping, this.TestTemplateTcmId) as ComponentTemplateData; if (templateData != null && templateData.RelatedSchemas.Any()) { var item = MainService.GetComponents(this.CurrentMapping, templateData.RelatedSchemas[0].IdRef).FirstOrDefault(); if (item != null) { this.TestItemTcmId = item.TcmId; tcmIdPath = MainService.GetIdPath(this.CurrentMapping, this.TestItemTcmId); } } } ItemType templateType = MainService.GetItemType(this.TestTemplateTcmId); TridionSelectorMode treeMode = templateType == ItemType.PageTemplate ? TridionSelectorMode.StructureGroup | TridionSelectorMode.Page : TridionSelectorMode.Folder | TridionSelectorMode.Component; this.treeTridionItem.ItemsSource = MainService.GetPublications(this.CurrentMapping).Expand(this.CurrentMapping, treeMode, tcmIdPath, this.TestItemTcmId).MakeExpandable(); this.treeTridionItem.IsEnabled = true; }
private void TreeViewItem_Expanded(object sender, RoutedEventArgs e) { ItemInfo item = ((TreeViewItem)e.OriginalSource).DataContext as ItemInfo; if (item == null) { return; } ItemType templateType = MainService.GetItemType(this.TestTemplateTcmId); TridionSelectorMode treeMode = templateType == ItemType.PageTemplate ? TridionSelectorMode.StructureGroup | TridionSelectorMode.Page : TridionSelectorMode.Folder | TridionSelectorMode.Component; MainService.OnItemExpanded(item, this.CurrentMapping, treeMode); }
public static List<ItemInfo> Expand(this List<ItemInfo> list, MappingInfo mapping, TridionSelectorMode tridionSelectorMode, List<string> tcmItemPath, string selectedTcmId) { if (tcmItemPath == null || String.IsNullOrEmpty(selectedTcmId)) return list; foreach (ItemInfo item in list) { if (tcmItemPath.Any(x => x == item.TcmId)) { item.IsExpanded = true; item.IsSelected = item.TcmId == selectedTcmId; if (item.IsSelected) continue; if (String.IsNullOrEmpty(item.TcmId)) continue; item.ChildItems = null; if (item.ItemType == ItemType.Publication) { if (tridionSelectorMode.HasFlag(TridionSelectorMode.Any)) { item.ChildItems = GetItemsByPublication(mapping, item.TcmId); } else if (tridionSelectorMode.HasFlag(TridionSelectorMode.Folder) && tridionSelectorMode.HasFlag(TridionSelectorMode.StructureGroup)) { item.ChildItems = GetContainersByPublication(mapping, item.TcmId); } else if (tridionSelectorMode.HasFlag(TridionSelectorMode.Folder)) { item.ChildItems = GetFoldersByPublication(mapping, item.TcmId); } else if (tridionSelectorMode.HasFlag(TridionSelectorMode.StructureGroup)) { item.ChildItems = GetStructureGroupsByPublication(mapping, item.TcmId); } } if (item.ItemType == ItemType.Folder) { if (tridionSelectorMode.HasFlag(TridionSelectorMode.Any)) { if (item.Title == "Categories and Keywords" && item.TcmId.StartsWith("catman-")) { item.ChildItems = GetCategoriesByPublication(mapping, item.TcmId.Replace("catman-", "")); } else if (item.Title == "Process Definitions" && item.TcmId.StartsWith("proc-")) { item.ChildItems = GetProcessDefinitionsByPublication(mapping, item.TcmId.Replace("proc-", "")); } else { item.ChildItems = GetItemsByParentContainer(mapping, item.TcmId); } } else { item.ChildItems = GetItemsByParentContainer(mapping, item.TcmId, tridionSelectorMode.GetItemTypes()); } } if (item.ItemType == ItemType.StructureGroup) { if (tridionSelectorMode.HasFlag(TridionSelectorMode.StructureGroup) && tridionSelectorMode.HasFlag(TridionSelectorMode.Page) || tridionSelectorMode.HasFlag(TridionSelectorMode.Any)) { item.ChildItems = GetItemsByParentContainer(mapping, item.TcmId); } else if (tridionSelectorMode.HasFlag(TridionSelectorMode.StructureGroup)) { item.ChildItems = GetStructureGroupsByParentStructureGroup(mapping, item.TcmId); } } if (item.ItemType == ItemType.Category) { item.ChildItems = GetKeywordsByCategory(mapping, item.TcmId); } if (item.ChildItems != null && item.ChildItems.Count > 0) { item.ChildItems.SetParent(item); } if (item.ChildItems != null && item.ChildItems.Count > 0) { item.ChildItems.Expand(mapping, tridionSelectorMode, tcmItemPath, selectedTcmId); } } else { if (item.ItemType == ItemType.Publication || item.ItemType == ItemType.Folder || item.ItemType == ItemType.StructureGroup || item.ItemType == ItemType.Category) item.ChildItems = new List<ItemInfo> { new ItemInfo { Title = "Loading..." } }; } } return list; }
public static void OnItemExpanded(ItemInfo item, MappingInfo mapping, TridionSelectorMode tridionSelectorMode) { if (item.ChildItems != null && item.ChildItems.All(x => x.Title != "Loading...")) return; if (String.IsNullOrEmpty(item.TcmId)) return; if (item.ItemType == ItemType.Publication) { if (tridionSelectorMode.HasFlag(TridionSelectorMode.Any)) { item.ChildItems = GetItemsByPublication(mapping, item.TcmId).MakeExpandable().SetParent(item); } else if (tridionSelectorMode.HasFlag(TridionSelectorMode.Folder) && tridionSelectorMode.HasFlag(TridionSelectorMode.StructureGroup)) { item.ChildItems = GetContainersByPublication(mapping, item.TcmId).MakeExpandable().SetParent(item); } else if (tridionSelectorMode.HasFlag(TridionSelectorMode.Folder)) { item.ChildItems = GetFoldersByPublication(mapping, item.TcmId).MakeExpandable().SetParent(item); } else if (tridionSelectorMode.HasFlag(TridionSelectorMode.StructureGroup)) { item.ChildItems = GetStructureGroupsByPublication(mapping, item.TcmId).MakeExpandable().SetParent(item); } } if (item.ItemType == ItemType.Folder) { if (tridionSelectorMode.HasFlag(TridionSelectorMode.Any)) { if (item.Title == "Categories and Keywords" && item.TcmId.StartsWith("catman-")) { item.ChildItems = GetCategoriesByPublication(mapping, item.TcmId.Replace("catman-", "")).MakeExpandable().SetParent(item); } else if (item.Title == "Process Definitions" && item.TcmId.StartsWith("proc-")) { item.ChildItems = GetProcessDefinitionsByPublication(mapping, item.TcmId.Replace("proc-", "")).MakeExpandable().SetParent(item); } else { item.ChildItems = GetItemsByParentContainer(mapping, item.TcmId).MakeExpandable().SetParent(item); } } else { item.ChildItems = GetItemsByParentContainer(mapping, item.TcmId, tridionSelectorMode.GetItemTypes()).MakeExpandable().SetParent(item); } } if (item.ItemType == ItemType.StructureGroup) { if (tridionSelectorMode.HasFlag(TridionSelectorMode.StructureGroup) && tridionSelectorMode.HasFlag(TridionSelectorMode.Page) || tridionSelectorMode.HasFlag(TridionSelectorMode.Any)) { item.ChildItems = GetItemsByParentContainer(mapping, item.TcmId).MakeExpandable().SetParent(item); } else if (tridionSelectorMode.HasFlag(TridionSelectorMode.StructureGroup)) { item.ChildItems = GetStructureGroupsByParentStructureGroup(mapping, item.TcmId).MakeExpandable().SetParent(item); } } if (item.ItemType == ItemType.Category) { item.ChildItems = GetKeywordsByCategory(mapping, item.TcmId).MakeExpandable().SetParent(item); } }
public static List<ItemInfo> Expand(this List<ItemInfo> list, MappingInfo mapping, TridionSelectorMode tridionSelectorMode, List<string> tcmIdPath, string selectedTcmId) { if (tcmIdPath == null || String.IsNullOrEmpty(selectedTcmId)) return list; foreach (ItemInfo item in list) { if (tcmIdPath.Any(x => x == item.TcmId)) { item.IsExpanded = true; item.IsSelected = item.TcmId == selectedTcmId; if (item.IsSelected) continue; if (String.IsNullOrEmpty(item.TcmId)) continue; item.ChildItems = null; if (item.ItemType == ItemType.Publication) { if (tridionSelectorMode == TridionSelectorMode.Folder) { item.ChildItems = GetFoldersByPublication(mapping, item.TcmId); } if (tridionSelectorMode == TridionSelectorMode.StructureGroup) { item.ChildItems = GetStructureGroupsByPublication(mapping, item.TcmId); } if (tridionSelectorMode == TridionSelectorMode.FolderAndStructureGroup) { item.ChildItems = GetFoldersAndStructureGroupsByPublication(mapping, item.TcmId); } } if (item.ItemType == ItemType.Folder) { item.ChildItems = GetFoldersByParentFolder(mapping, item.TcmId); } if (item.ItemType == ItemType.StructureGroup) { item.ChildItems = GetStructureGroupsByParentStructureGroup(mapping, item.TcmId); } if (item.ChildItems != null && item.ChildItems.Count > 0) { item.ChildItems.SetParent(item); } if (item.ChildItems != null && item.ChildItems.Count > 0) { item.ChildItems.Expand(mapping, tridionSelectorMode, tcmIdPath, selectedTcmId); } } else { item.ChildItems = new List<ItemInfo> { new ItemInfo { Title = "Loading..." } }; } } return list; }