@itwin/presentation-frontend 5.0.0-dev.5 → 5.0.0-dev.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -1
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts +3 -3
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js +1 -1
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.js +5 -5
- package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts +4 -2
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.js +6 -1
- package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/StreamedResponseGenerator.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +4 -2
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +22 -14
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +2 -3
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +2 -4
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts +3 -2
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js +6 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts +25 -7
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js +168 -81
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend.js.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts +3 -3
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/Diagnostics.js.map +1 -1
- package/lib/esm/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.js +5 -5
- package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.d.ts +4 -2
- package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.js +6 -1
- package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/StreamedResponseGenerator.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +4 -2
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +23 -15
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +2 -3
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +3 -5
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts +3 -2
- package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js +6 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts +25 -7
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.js +169 -82
- package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/esm/presentation-frontend.js.map +1 -1
- package/package.json +18 -18
|
@@ -42,9 +42,14 @@ export class SelectionHandler {
|
|
|
42
42
|
* Destructor. Must be called before disposing this object to make sure it cleans
|
|
43
43
|
* up correctly.
|
|
44
44
|
*/
|
|
45
|
-
dispose() {
|
|
45
|
+
[Symbol.dispose]() {
|
|
46
46
|
this._disposables.dispose();
|
|
47
47
|
}
|
|
48
|
+
/** @deprecated in 5.0 Use [Symbol.dispose] instead. */
|
|
49
|
+
// istanbul ignore next
|
|
50
|
+
dispose() {
|
|
51
|
+
this[Symbol.dispose]();
|
|
52
|
+
}
|
|
48
53
|
/** Called to check whether the event should be handled by this handler */
|
|
49
54
|
shouldHandle(evt) {
|
|
50
55
|
if (this.name === evt.source) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionHandler.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"SelectionHandler.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAiCrD;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAkB3B;;OAEG;IACH,YAAY,KAA4B;QAyBxC;;;WAGG;QACO,uBAAkB,GAAG,CAAC,GAA6B,EAAE,QAA4B,EAAQ,EAAE;YACnG,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9C,OAAO;YACT,CAAC;YAED,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,IAAI,CAAC,QAAQ,CAAC,GAAG,EAA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CAAC;IACvD,CAAC;IAED;;;;OAIG;IACI,cAAc,CAAC,IAAU,EAAE,QAAgB,CAAC;QACjD,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC1F,CAAC;IAED;;;;OAIG;IACI,mBAAmB,CAAC,IAAU,EAAE,QAAgB,CAAC;QACtD,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/F,CAAC;IAED;;;;OAIG;IACI,gBAAgB,CAAC,IAAU,EAAE,QAAgB,CAAC;QACnD,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5F,CAAC;IAED;;;OAGG;IACI,cAAc,CAAC,QAAgB,CAAC;QACrC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACpF,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\nimport { DisposableList } from \"@itwin/core-bentley\";\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { Keys, KeySet } from \"@itwin/presentation-common\";\nimport { ISelectionProvider } from \"./ISelectionProvider\";\nimport { SelectionChangeEventArgs, SelectionChangesListener } from \"./SelectionChangeEvent\";\nimport { SelectionManager } from \"./SelectionManager\";\n\n/**\n * Properties for creating a `SelectionHandler` instance.\n * @public\n */\nexport interface SelectionHandlerProps {\n /** SelectionManager used to store overall selection. */\n manager: SelectionManager;\n /** iModel connection the selection changes will be associated with. */\n imodel: IModelConnection;\n /**\n * Name of the selection handler. This is an identifier of what caused the\n * selection to change, set as `SelectionChangeEventArgs.source` when firing\n * selection change events. `SelectionHandler.shouldHandle` uses `name` to filter\n * events that it doesn't need to handle.\n */\n name: string;\n /**\n * ID of presentation ruleset used by the component using this handler. The ID is set as\n * `SelectionChangeEventArgs.rulesetId` when making selection changes and event\n * listeners can use or ignore this information.\n */\n rulesetId?: string;\n /** Callback function called when selection changes. */\n onSelect?: SelectionChangesListener;\n}\n\n/**\n * A class that handles selection changes and helps to change\n * internal the selection state.\n *\n * @public\n */\nexport class SelectionHandler implements Disposable {\n private _inSelect: boolean;\n private _disposables: DisposableList;\n\n /** Selection manager used by this handler to manage selection */\n public readonly manager: SelectionManager;\n /** Name that's used as `SelectionChangeEventArgs.source` when making selection changes */\n public name: string;\n /** iModel whose selection is being handled */\n public imodel: IModelConnection;\n /**\n * Id of a ruleset selection changes will be associated with.\n * @see `SelectionHandlerProps.rulesetId`\n */\n public rulesetId?: string;\n /** Callback function called when selection changes */\n public onSelect?: SelectionChangesListener;\n\n /**\n * Constructor.\n */\n constructor(props: SelectionHandlerProps) {\n this._inSelect = false;\n this.manager = props.manager;\n this._disposables = new DisposableList();\n this.name = props.name;\n this.rulesetId = props.rulesetId;\n this.imodel = props.imodel;\n this.onSelect = props.onSelect;\n this._disposables.add(this.manager.selectionChange.addListener(this.onSelectionChanged));\n }\n\n /**\n * Destructor. Must be called before disposing this object to make sure it cleans\n * up correctly.\n */\n public [Symbol.dispose](): void {\n this._disposables.dispose();\n }\n\n /** @deprecated in 5.0 Use [Symbol.dispose] instead. */\n // istanbul ignore next\n public dispose() {\n this[Symbol.dispose]();\n }\n\n /**\n * Called when the selection changes. Handles this callback by first checking whether\n * the event should be handled at all (using the `shouldHandle` method) and then calling `onSelect`\n */\n protected onSelectionChanged = (evt: SelectionChangeEventArgs, provider: ISelectionProvider): void => {\n if (!this.onSelect || !this.shouldHandle(evt)) {\n return;\n }\n\n this._inSelect = true;\n this.onSelect(evt, provider);\n this._inSelect = false;\n };\n\n /** Called to check whether the event should be handled by this handler */\n protected shouldHandle(evt: SelectionChangeEventArgs): boolean {\n if (this.name === evt.source) {\n return false;\n }\n return true;\n }\n\n /** Get selection levels for the imodel managed by this handler */\n public getSelectionLevels(): number[] {\n return this.manager.getSelectionLevels(this.imodel);\n }\n\n /**\n * Get selection for the imodel managed by this handler.\n * @param level Level of the selection to get. Defaults to 0.\n */\n public getSelection(level?: number): Readonly<KeySet> {\n return this.manager.getSelection(this.imodel, level);\n }\n\n /**\n * Add to selection.\n * @param keys The keys to add to selection.\n * @param level Level of the selection.\n */\n public addToSelection(keys: Keys, level: number = 0): void {\n if (this._inSelect) {\n return;\n }\n\n return this.manager.addToSelection(this.name, this.imodel, keys, level, this.rulesetId);\n }\n\n /**\n * Remove from selection.\n * @param keys The keys to remove from selection.\n * @param level Level of the selection.\n */\n public removeFromSelection(keys: Keys, level: number = 0): void {\n if (this._inSelect) {\n return;\n }\n\n return this.manager.removeFromSelection(this.name, this.imodel, keys, level, this.rulesetId);\n }\n\n /**\n * Change selection.\n * @param keys The keys indicating the new selection.\n * @param level Level of the selection.\n */\n public replaceSelection(keys: Keys, level: number = 0): void {\n if (this._inSelect) {\n return;\n }\n\n return this.manager.replaceSelection(this.name, this.imodel, keys, level, this.rulesetId);\n }\n\n /**\n * Clear selection.\n * @param level Level of the selection.\n */\n public clearSelection(level: number = 0): void {\n if (this._inSelect) {\n return;\n }\n\n return this.manager.clearSelection(this.name, this.imodel, level, this.rulesetId);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionHelper.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAQ,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;;GAGG;AACH,MAAM,OAAO,eAAe;IAC1B,uBAAuB;IACvB,gBAAuB,CAAC;IAExB;;;;OAIG;IACI,MAAM,CAAC,mBAAmB,CAAC,IAAoB;QACpD,MAAM,MAAM,GAAG,IAAI,KAAK,EAAO,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAQ,EAAE,EAAE;YACxB,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;gBACvB,IAAI,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;oBACpC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;gBACnC,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACnB,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACnB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"SelectionHelper.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAQ,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;;GAGG;AACH,MAAM,OAAO,eAAe;IAC1B,uBAAuB;IACvB,gBAAuB,CAAC;IAExB;;;;OAIG;IACI,MAAM,CAAC,mBAAmB,CAAC,IAAoB;QACpD,MAAM,MAAM,GAAG,IAAI,KAAK,EAAO,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAQ,EAAE,EAAE;YACxB,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;gBACvB,IAAI,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;oBACpC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;gBACnC,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACnB,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACnB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\nimport { Key, Keys, NodeKey } from \"@itwin/presentation-common\";\n\n/**\n * Helper class for working with selection.\n * @public\n */\nexport class SelectionHelper {\n // istanbul ignore next\n private constructor() {}\n\n /**\n * Re-map the given keyset for selection. This means all instance node keys get converted\n * to instance keys, because in that case we want to select instances instead of nodes. All\n * other types of keys ar left as is.\n */\n public static getKeysForSelection(keys: Readonly<Keys>): Key[] {\n const result = new Array<Key>();\n keys.forEach((key: Key) => {\n if (Key.isNodeKey(key)) {\n if (NodeKey.isInstancesNodeKey(key)) {\n result.push(...key.instanceKeys);\n } else {\n result.push(key);\n }\n } else {\n result.push(key);\n }\n });\n return result;\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module UnifiedSelection
|
|
3
3
|
*/
|
|
4
|
-
import { Id64Arg
|
|
4
|
+
import { Id64Arg } from "@itwin/core-bentley";
|
|
5
5
|
import { IModelConnection } from "@itwin/core-frontend";
|
|
6
6
|
import { Keys, KeySet, SelectionScope, SelectionScopeProps } from "@itwin/presentation-common";
|
|
7
7
|
import { SelectionStorage } from "@itwin/unified-selection";
|
|
@@ -21,13 +21,21 @@ export interface SelectionManagerProps {
|
|
|
21
21
|
* and maintains storage.
|
|
22
22
|
*/
|
|
23
23
|
selectionStorage?: SelectionStorage;
|
|
24
|
+
/**
|
|
25
|
+
* An optional function that returns a key for the given iModel. The key is what "glues" iModel selection
|
|
26
|
+
* changes made in `selectionStorage`, where iModels are identified by key, and `SelectionManager`, where
|
|
27
|
+
* iModels are specified as `IModelConnection`.
|
|
28
|
+
*
|
|
29
|
+
* If not provided, [IModelConnection.key]($core-frontend) or [IModelConnection.name]($core-frontend) is used.
|
|
30
|
+
*/
|
|
31
|
+
imodelKeyFactory?: (imodel: IModelConnection) => string;
|
|
24
32
|
}
|
|
25
33
|
/**
|
|
26
34
|
* The selection manager which stores the overall selection.
|
|
27
35
|
* @public
|
|
28
36
|
*/
|
|
29
|
-
export declare class SelectionManager implements ISelectionProvider {
|
|
30
|
-
private
|
|
37
|
+
export declare class SelectionManager implements ISelectionProvider, Disposable {
|
|
38
|
+
private _imodelKeyFactory;
|
|
31
39
|
private _imodelToolSelectionSyncHandlers;
|
|
32
40
|
private _hiliteSetProviders;
|
|
33
41
|
private _ownsStorage;
|
|
@@ -36,6 +44,11 @@ export declare class SelectionManager implements ISelectionProvider {
|
|
|
36
44
|
private _selectionChanges;
|
|
37
45
|
private _selectionEventsSubscription;
|
|
38
46
|
private _listeners;
|
|
47
|
+
/**
|
|
48
|
+
* Underlying selection storage used by this selection manager. Ideally, consumers should use
|
|
49
|
+
* the storage directly instead of using this manager to manipulate selection.
|
|
50
|
+
*/
|
|
51
|
+
readonly selectionStorage: SelectionStorage;
|
|
39
52
|
/** An event which gets broadcasted on selection changes */
|
|
40
53
|
readonly selectionChange: SelectionChangeEvent;
|
|
41
54
|
/** Manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */
|
|
@@ -44,6 +57,8 @@ export declare class SelectionManager implements ISelectionProvider {
|
|
|
44
57
|
* Creates an instance of SelectionManager.
|
|
45
58
|
*/
|
|
46
59
|
constructor(props: SelectionManagerProps);
|
|
60
|
+
[Symbol.dispose](): void;
|
|
61
|
+
/** @deprecated in 5.0. Use [Symbol.dispose] instead. */
|
|
47
62
|
dispose(): void;
|
|
48
63
|
private onConnectionClose;
|
|
49
64
|
/** @internal */
|
|
@@ -53,10 +68,13 @@ export declare class SelectionManager implements ISelectionProvider {
|
|
|
53
68
|
*/
|
|
54
69
|
setSyncWithIModelToolSelection(imodel: IModelConnection, sync?: boolean): void;
|
|
55
70
|
/**
|
|
56
|
-
* Temporarily suspends tool selection synchronization until the returned `
|
|
71
|
+
* Temporarily suspends tool selection synchronization until the returned `Disposable`
|
|
57
72
|
* is disposed.
|
|
58
73
|
*/
|
|
59
|
-
suspendIModelToolSelectionSync(imodel: IModelConnection):
|
|
74
|
+
suspendIModelToolSelectionSync(imodel: IModelConnection): {
|
|
75
|
+
[Symbol.dispose]: () => void;
|
|
76
|
+
dispose: () => void;
|
|
77
|
+
};
|
|
60
78
|
/** Get the selection levels currently stored in this manager for the specified imodel */
|
|
61
79
|
getSelectionLevels(imodel: IModelConnection): number[];
|
|
62
80
|
/**
|
|
@@ -147,7 +165,7 @@ export declare class SelectionManager implements ISelectionProvider {
|
|
|
147
165
|
private streamSelectionEvents;
|
|
148
166
|
}
|
|
149
167
|
/** @internal */
|
|
150
|
-
export declare class ToolSelectionSyncHandler implements
|
|
168
|
+
export declare class ToolSelectionSyncHandler implements Disposable {
|
|
151
169
|
private _selectionSourceName;
|
|
152
170
|
private _logicalSelection;
|
|
153
171
|
private _imodel;
|
|
@@ -155,7 +173,7 @@ export declare class ToolSelectionSyncHandler implements IDisposable {
|
|
|
155
173
|
private _asyncsTracker;
|
|
156
174
|
isSuspended?: boolean;
|
|
157
175
|
constructor(imodel: IModelConnection, logicalSelection: SelectionManager);
|
|
158
|
-
dispose(): void;
|
|
176
|
+
[Symbol.dispose](): void;
|
|
159
177
|
/** note: used only it tests */
|
|
160
178
|
get pendingAsyncs(): Set<string>;
|
|
161
179
|
private onToolSelectionChanged;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionManager.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAQ,OAAO,EAAa,
|
|
1
|
+
{"version":3,"file":"SelectionManager.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAQ,OAAO,EAAa,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAA2D,MAAM,sBAAsB,CAAC;AACjH,OAAO,EAAoD,IAAI,EAAE,MAAM,EAAW,cAAc,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC1J,OAAO,EAKL,gBAAgB,EAIjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAAqB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAiD,MAAM,wBAAwB,CAAC;AAC7G,OAAO,EAA6B,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAE7F;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,oGAAoG;IACpG,MAAM,EAAE,sBAAsB,CAAC;IAE/B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAEpC;;;;;;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AK,GAAE,MAAU,EACjB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC;IAKhB;;;OAGG;IACU,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IAIvE;;;OAGG;IACI,oBAAoB,CAAC,MAAM,EAAE,gBAAgB;IAIpD,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,qBAAqB;CA8B9B;AAWD,gBAAgB;AAChB,qBAAa,wBAAyB,YAAW,UAAU;IACzD,OAAO,CAAC,oBAAoB,CAAU;IACtC,OAAO,CAAC,iBAAiB,CAAmB;IAC5C,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,uCAAuC,CAAa;IAC5D,OAAO,CAAC,cAAc,CAA2B;IAC1C,WAAW,CAAC,EAAE,OAAO,CAAC;gBAEV,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB;IAMxE,CAAC,MAAM,CAAC,OAAO,CAAC;IAIvB,+BAA+B;IAC/B,IAAW,aAAa,gBAEvB;IAED,OAAO,CAAC,sBAAsB,CAuD5B;CACH"}
|
|
@@ -5,8 +5,60 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module UnifiedSelection
|
|
7
7
|
*/
|
|
8
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
9
|
+
if (value !== null && value !== void 0) {
|
|
10
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
11
|
+
var dispose, inner;
|
|
12
|
+
if (async) {
|
|
13
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
14
|
+
dispose = value[Symbol.asyncDispose];
|
|
15
|
+
}
|
|
16
|
+
if (dispose === void 0) {
|
|
17
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
18
|
+
dispose = value[Symbol.dispose];
|
|
19
|
+
if (async) inner = dispose;
|
|
20
|
+
}
|
|
21
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
22
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
23
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
24
|
+
}
|
|
25
|
+
else if (async) {
|
|
26
|
+
env.stack.push({ async: true });
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
};
|
|
30
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
31
|
+
return function (env) {
|
|
32
|
+
function fail(e) {
|
|
33
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
34
|
+
env.hasError = true;
|
|
35
|
+
}
|
|
36
|
+
var r, s = 0;
|
|
37
|
+
function next() {
|
|
38
|
+
while (r = env.stack.pop()) {
|
|
39
|
+
try {
|
|
40
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
41
|
+
if (r.dispose) {
|
|
42
|
+
var result = r.dispose.call(r.value);
|
|
43
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
44
|
+
}
|
|
45
|
+
else s |= 1;
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
fail(e);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
52
|
+
if (env.hasError) throw env.error;
|
|
53
|
+
}
|
|
54
|
+
return next();
|
|
55
|
+
};
|
|
56
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
57
|
+
var e = new Error(message);
|
|
58
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
59
|
+
});
|
|
8
60
|
import { defer, EMPTY, mergeMap, of, Subject, takeUntil, tap } from "rxjs";
|
|
9
|
-
import { Id64
|
|
61
|
+
import { Id64 } from "@itwin/core-bentley";
|
|
10
62
|
import { IModelConnection, SelectionSetEventType } from "@itwin/core-frontend";
|
|
11
63
|
import { AsyncTasksTracker, KeySet, NodeKey } from "@itwin/presentation-common";
|
|
12
64
|
import { createStorage, TRANSIENT_ELEMENT_CLASSNAME, } from "@itwin/unified-selection";
|
|
@@ -25,34 +77,41 @@ export class SelectionManager {
|
|
|
25
77
|
constructor(props) {
|
|
26
78
|
this._imodelToolSelectionSyncHandlers = new Map();
|
|
27
79
|
this._hiliteSetProviders = new Map();
|
|
28
|
-
this._knownIModels = new
|
|
80
|
+
this._knownIModels = new Set();
|
|
29
81
|
this._currentSelection = new CurrentSelectionStorage();
|
|
30
82
|
this._selectionChanges = new Subject();
|
|
31
83
|
this._listeners = [];
|
|
32
84
|
this.selectionChange = new SelectionChangeEvent();
|
|
33
85
|
this.scopes = props.scopes;
|
|
34
|
-
this.
|
|
86
|
+
this.selectionStorage = props.selectionStorage ?? createStorage();
|
|
87
|
+
this._imodelKeyFactory = props.imodelKeyFactory ?? ((imodel) => (imodel.key.length ? imodel.key : imodel.name));
|
|
35
88
|
this._ownsStorage = props.selectionStorage === undefined;
|
|
36
|
-
this.
|
|
89
|
+
this.selectionStorage.selectionChangeEvent.addListener((args) => this._selectionChanges.next(args));
|
|
37
90
|
this._selectionEventsSubscription = this.streamSelectionEvents();
|
|
38
91
|
this._listeners.push(IModelConnection.onOpen.addListener((imodel) => {
|
|
39
|
-
this._knownIModels.
|
|
92
|
+
this._knownIModels.add(imodel);
|
|
40
93
|
}));
|
|
41
94
|
this._listeners.push(IModelConnection.onClose.addListener((imodel) => {
|
|
42
95
|
this.onConnectionClose(imodel);
|
|
43
96
|
}));
|
|
44
97
|
}
|
|
45
|
-
dispose() {
|
|
98
|
+
[Symbol.dispose]() {
|
|
46
99
|
this._selectionEventsSubscription.unsubscribe();
|
|
47
100
|
this._listeners.forEach((dispose) => dispose());
|
|
48
101
|
}
|
|
102
|
+
/** @deprecated in 5.0. Use [Symbol.dispose] instead. */
|
|
103
|
+
// istanbul ignore next
|
|
104
|
+
dispose() {
|
|
105
|
+
this[Symbol.dispose]();
|
|
106
|
+
}
|
|
49
107
|
onConnectionClose(imodel) {
|
|
108
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
50
109
|
this._hiliteSetProviders.delete(imodel);
|
|
51
|
-
this._knownIModels.delete(imodel
|
|
52
|
-
this._currentSelection.clear(
|
|
110
|
+
this._knownIModels.delete(imodel);
|
|
111
|
+
this._currentSelection.clear(imodelKey);
|
|
53
112
|
if (this._ownsStorage) {
|
|
54
113
|
this.clearSelection("Connection Close Event", imodel);
|
|
55
|
-
this.
|
|
114
|
+
this.selectionStorage.clearStorage({ imodelKey });
|
|
56
115
|
}
|
|
57
116
|
}
|
|
58
117
|
/** @internal */
|
|
@@ -81,27 +140,30 @@ export class SelectionManager {
|
|
|
81
140
|
}
|
|
82
141
|
else {
|
|
83
142
|
this._imodelToolSelectionSyncHandlers.delete(imodel);
|
|
84
|
-
registration.handler.dispose();
|
|
143
|
+
registration.handler[Symbol.dispose]();
|
|
85
144
|
}
|
|
86
145
|
}
|
|
87
146
|
}
|
|
88
147
|
}
|
|
89
148
|
/**
|
|
90
|
-
* Temporarily suspends tool selection synchronization until the returned `
|
|
149
|
+
* Temporarily suspends tool selection synchronization until the returned `Disposable`
|
|
91
150
|
* is disposed.
|
|
92
151
|
*/
|
|
93
152
|
suspendIModelToolSelectionSync(imodel) {
|
|
94
153
|
const registration = this._imodelToolSelectionSyncHandlers.get(imodel);
|
|
95
154
|
if (!registration) {
|
|
96
|
-
|
|
155
|
+
const noop = () => { };
|
|
156
|
+
return { [Symbol.dispose]: noop, dispose: noop };
|
|
97
157
|
}
|
|
98
158
|
const wasSuspended = registration.handler.isSuspended;
|
|
99
159
|
registration.handler.isSuspended = true;
|
|
100
|
-
|
|
160
|
+
const doDispose = () => (registration.handler.isSuspended = wasSuspended);
|
|
161
|
+
return { [Symbol.dispose]: doDispose, dispose: doDispose };
|
|
101
162
|
}
|
|
102
163
|
/** Get the selection levels currently stored in this manager for the specified imodel */
|
|
103
164
|
getSelectionLevels(imodel) {
|
|
104
|
-
|
|
165
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
166
|
+
return this.selectionStorage.getSelectionLevels({ imodelKey });
|
|
105
167
|
}
|
|
106
168
|
/**
|
|
107
169
|
* Get the selection currently stored in this manager
|
|
@@ -111,39 +173,39 @@ export class SelectionManager {
|
|
|
111
173
|
* latest selection after changes.
|
|
112
174
|
*/
|
|
113
175
|
getSelection(imodel, level = 0) {
|
|
114
|
-
|
|
176
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
177
|
+
return this._currentSelection.getSelection(imodelKey, level);
|
|
115
178
|
}
|
|
116
179
|
handleEvent(evt) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
180
|
+
const imodelKey = this._imodelKeyFactory(evt.imodel);
|
|
181
|
+
this._knownIModels.add(evt.imodel);
|
|
120
182
|
switch (evt.changeType) {
|
|
121
183
|
case SelectionChangeType.Add:
|
|
122
|
-
this.
|
|
123
|
-
|
|
184
|
+
this.selectionStorage.addToSelection({
|
|
185
|
+
imodelKey,
|
|
124
186
|
source: evt.source,
|
|
125
187
|
level: evt.level,
|
|
126
188
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
127
189
|
});
|
|
128
190
|
break;
|
|
129
191
|
case SelectionChangeType.Remove:
|
|
130
|
-
this.
|
|
131
|
-
|
|
192
|
+
this.selectionStorage.removeFromSelection({
|
|
193
|
+
imodelKey,
|
|
132
194
|
source: evt.source,
|
|
133
195
|
level: evt.level,
|
|
134
196
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
135
197
|
});
|
|
136
198
|
break;
|
|
137
199
|
case SelectionChangeType.Replace:
|
|
138
|
-
this.
|
|
139
|
-
|
|
200
|
+
this.selectionStorage.replaceSelection({
|
|
201
|
+
imodelKey,
|
|
140
202
|
source: evt.source,
|
|
141
203
|
level: evt.level,
|
|
142
204
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
143
205
|
});
|
|
144
206
|
break;
|
|
145
207
|
case SelectionChangeType.Clear:
|
|
146
|
-
this.
|
|
208
|
+
this.selectionStorage.clearSelection({ imodelKey, source: evt.source, level: evt.level });
|
|
147
209
|
break;
|
|
148
210
|
}
|
|
149
211
|
}
|
|
@@ -290,9 +352,9 @@ export class SelectionManager {
|
|
|
290
352
|
streamSelectionEvents() {
|
|
291
353
|
return this._selectionChanges
|
|
292
354
|
.pipe(mergeMap((args) => {
|
|
293
|
-
const currentSelectables = this.
|
|
355
|
+
const currentSelectables = this.selectionStorage.getSelection({ imodelKey: args.imodelKey, level: args.level });
|
|
294
356
|
return this._currentSelection.computeSelection(args.imodelKey, args.level, currentSelectables, args.selectables).pipe(mergeMap(({ level, changedSelection }) => {
|
|
295
|
-
const imodel = this._knownIModels.
|
|
357
|
+
const imodel = findIModel(this._knownIModels, this._imodelKeyFactory, args.imodelKey);
|
|
296
358
|
// istanbul ignore if
|
|
297
359
|
if (!imodel) {
|
|
298
360
|
return EMPTY;
|
|
@@ -314,66 +376,80 @@ export class SelectionManager {
|
|
|
314
376
|
});
|
|
315
377
|
}
|
|
316
378
|
}
|
|
379
|
+
function findIModel(set, imodelKeyFactory, key) {
|
|
380
|
+
for (const imodel of set) {
|
|
381
|
+
if (imodelKeyFactory(imodel) === key) {
|
|
382
|
+
return imodel;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return undefined;
|
|
386
|
+
}
|
|
317
387
|
/** @internal */
|
|
318
388
|
export class ToolSelectionSyncHandler {
|
|
319
389
|
constructor(imodel, logicalSelection) {
|
|
320
390
|
this._selectionSourceName = "Tool";
|
|
321
391
|
this._asyncsTracker = new AsyncTasksTracker();
|
|
322
392
|
this.onToolSelectionChanged = async (ev) => {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
const parsedIds = parseIds(ids);
|
|
358
|
-
await using(this._asyncsTracker.trackAsyncTask(), async (_r) => {
|
|
393
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
394
|
+
try {
|
|
395
|
+
// ignore selection change event if the handler is suspended
|
|
396
|
+
if (this.isSuspended) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
// this component only cares about its own imodel
|
|
400
|
+
const imodel = ev.set.iModel;
|
|
401
|
+
if (imodel !== this._imodel) {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
// determine the level of selection changes
|
|
405
|
+
// wip: may want to allow selecting at different levels?
|
|
406
|
+
const selectionLevel = 0;
|
|
407
|
+
let ids;
|
|
408
|
+
switch (ev.type) {
|
|
409
|
+
case SelectionSetEventType.Add:
|
|
410
|
+
ids = ev.additions;
|
|
411
|
+
break;
|
|
412
|
+
case SelectionSetEventType.Replace:
|
|
413
|
+
ids = ev.set.active;
|
|
414
|
+
break;
|
|
415
|
+
default:
|
|
416
|
+
ids = ev.removals;
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
419
|
+
// we're always using scoped selection changer even if the scope is set to "element" - that
|
|
420
|
+
// makes sure we're adding to selection keys with concrete classes and not "BisCore:Element", which
|
|
421
|
+
// we can't because otherwise our keys compare fails (presentation components load data with
|
|
422
|
+
// concrete classes)
|
|
423
|
+
const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, createSelectionScopeProps(this._logicalSelection.scopes.activeScope));
|
|
424
|
+
const _r = __addDisposableResource(env_1, this._asyncsTracker.trackAsyncTask(), false);
|
|
359
425
|
switch (ev.type) {
|
|
360
426
|
case SelectionSetEventType.Add:
|
|
361
|
-
await changer.add(
|
|
427
|
+
await changer.add(ids, selectionLevel);
|
|
362
428
|
break;
|
|
363
429
|
case SelectionSetEventType.Replace:
|
|
364
|
-
await changer.replace(
|
|
430
|
+
await changer.replace(ids, selectionLevel);
|
|
365
431
|
break;
|
|
366
432
|
case SelectionSetEventType.Remove:
|
|
367
|
-
await changer.remove(
|
|
433
|
+
await changer.remove(ids, selectionLevel);
|
|
434
|
+
break;
|
|
435
|
+
case SelectionSetEventType.Clear:
|
|
436
|
+
await changer.clear(selectionLevel);
|
|
368
437
|
break;
|
|
369
438
|
}
|
|
370
|
-
}
|
|
439
|
+
}
|
|
440
|
+
catch (e_1) {
|
|
441
|
+
env_1.error = e_1;
|
|
442
|
+
env_1.hasError = true;
|
|
443
|
+
}
|
|
444
|
+
finally {
|
|
445
|
+
__disposeResources(env_1);
|
|
446
|
+
}
|
|
371
447
|
};
|
|
372
448
|
this._imodel = imodel;
|
|
373
449
|
this._logicalSelection = logicalSelection;
|
|
374
450
|
this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);
|
|
375
451
|
}
|
|
376
|
-
dispose() {
|
|
452
|
+
[Symbol.dispose]() {
|
|
377
453
|
this._imodelToolSelectionListenerDisposeFunc();
|
|
378
454
|
}
|
|
379
455
|
/** note: used only it tests */
|
|
@@ -381,7 +457,7 @@ export class ToolSelectionSyncHandler {
|
|
|
381
457
|
return this._asyncsTracker.pendingAsyncs;
|
|
382
458
|
}
|
|
383
459
|
}
|
|
384
|
-
const
|
|
460
|
+
const parseElementIds = (ids) => {
|
|
385
461
|
let allPersistent = true;
|
|
386
462
|
let allTransient = true;
|
|
387
463
|
for (const id of Id64.iterable(ids)) {
|
|
@@ -416,12 +492,11 @@ const parseIds = (ids) => {
|
|
|
416
492
|
}
|
|
417
493
|
return { persistent: persistentElementIds, transient: transientElementIds };
|
|
418
494
|
};
|
|
419
|
-
function
|
|
420
|
-
for (const id of Id64.iterable(
|
|
421
|
-
|
|
495
|
+
function addKeys(target, className, ids) {
|
|
496
|
+
for (const id of Id64.iterable(ids)) {
|
|
497
|
+
target.add({ className, id });
|
|
422
498
|
}
|
|
423
499
|
}
|
|
424
|
-
/** @internal */
|
|
425
500
|
class ScopedSelectionChanger {
|
|
426
501
|
constructor(name, imodel, manager, scope) {
|
|
427
502
|
this.name = name;
|
|
@@ -432,21 +507,33 @@ class ScopedSelectionChanger {
|
|
|
432
507
|
async clear(level) {
|
|
433
508
|
this.manager.clearSelection(this.name, this.imodel, level);
|
|
434
509
|
}
|
|
435
|
-
async add(
|
|
436
|
-
const keys = await this
|
|
437
|
-
addTransientKeys(transientIds, keys);
|
|
510
|
+
async add(ids, level) {
|
|
511
|
+
const keys = await this.#computeSelection(ids);
|
|
438
512
|
this.manager.addToSelection(this.name, this.imodel, keys, level);
|
|
439
513
|
}
|
|
440
|
-
async remove(
|
|
441
|
-
const keys = await this
|
|
442
|
-
addTransientKeys(transientIds, keys);
|
|
514
|
+
async remove(ids, level) {
|
|
515
|
+
const keys = await this.#computeSelection(ids);
|
|
443
516
|
this.manager.removeFromSelection(this.name, this.imodel, keys, level);
|
|
444
517
|
}
|
|
445
|
-
async replace(
|
|
446
|
-
const keys = await this
|
|
447
|
-
addTransientKeys(transientIds, keys);
|
|
518
|
+
async replace(ids, level) {
|
|
519
|
+
const keys = await this.#computeSelection(ids);
|
|
448
520
|
this.manager.replaceSelection(this.name, this.imodel, keys, level);
|
|
449
521
|
}
|
|
522
|
+
async #computeSelection(ids) {
|
|
523
|
+
let keys = new KeySet();
|
|
524
|
+
if (ids.elements) {
|
|
525
|
+
const { persistent, transient } = parseElementIds(ids.elements);
|
|
526
|
+
keys = await this.manager.scopes.computeSelection(this.imodel, persistent, this.scope);
|
|
527
|
+
addKeys(keys, TRANSIENT_ELEMENT_CLASSNAME, transient);
|
|
528
|
+
}
|
|
529
|
+
if (ids.models) {
|
|
530
|
+
addKeys(keys, "BisCore.Model", ids.models);
|
|
531
|
+
}
|
|
532
|
+
if (ids.subcategories) {
|
|
533
|
+
addKeys(keys, "BisCore.SubCategory", ids.subcategories);
|
|
534
|
+
}
|
|
535
|
+
return keys;
|
|
536
|
+
}
|
|
450
537
|
}
|
|
451
538
|
/** Stores current selection in `KeySet` format per iModel. */
|
|
452
539
|
class CurrentSelectionStorage {
|