|
9 | 9 |
|
10 | 10 | namespace RevitDBExplorer.Domain.RevitDatabaseQuery.Parser.Commands |
11 | 11 | { |
12 | | - internal class CategoryCmdDefinition : ICommandDefinition, INeedInitialization, IOfferArgumentAutocompletion |
| 12 | + internal class CategoryCmdDefinition : ICommandDefinition, INeedInitializationWithDocument, IOfferArgumentAutocompletion |
13 | 13 | { |
14 | 14 | private static readonly AutocompleteItem AutocompleteItem = new AutocompleteItem("c: ", "c:[category]", "select elements of given category", AutocompleteItemGroups.Commands); |
15 | 15 | private readonly DataBucket<CategoryCmdArgument> dataBucket = new DataBucket<CategoryCmdArgument>(0.59); |
16 | 16 |
|
17 | 17 |
|
18 | | - public void Init() |
| 18 | + public void Init(Document document) |
19 | 19 | { |
20 | | - var allFilterableCategories = ParameterFilterUtilities.GetAllFilterableCategories(); |
| 20 | + dataBucket.Clear(); |
| 21 | + |
| 22 | + var categories = document.Settings.Categories; |
21 | 23 |
|
22 | | - foreach (ElementId categoryId in allFilterableCategories) |
| 24 | + foreach (Category category in categories) |
23 | 25 | { |
24 | | - var category = (BuiltInCategory)categoryId.Value(); |
25 | | - var label = LabelUtils.GetLabelFor(category); |
| 26 | + var builtInCategory = category.BuiltInCategory; |
| 27 | + |
| 28 | + var label = LabelUtils.GetLabelFor(builtInCategory); |
26 | 29 |
|
27 | | - var strCategory = category.ToString(); |
| 30 | + var strCategory = builtInCategory.ToString(); |
28 | 31 |
|
29 | | - if (!Category.IsBuiltInCategoryValid(category)) |
| 32 | + if (!Category.IsBuiltInCategoryValid(builtInCategory)) |
30 | 33 | { |
31 | 34 | continue; |
32 | 35 | } |
33 | | - dataBucket.Add(new AutocompleteItem(strCategory, strCategory, label), new CategoryCmdArgument(category), label, strCategory); |
| 36 | + dataBucket.Add(new AutocompleteItem(strCategory, strCategory, label), new CategoryCmdArgument(builtInCategory), label, strCategory); |
34 | 37 | } |
35 | 38 |
|
36 | 39 | dataBucket.Rebuild(); |
|
0 commit comments