@itwin/presentation-frontend 5.0.0-dev.9 → 5.0.0-dev.90
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 +53 -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 +11 -9
- 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 +2 -1
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.js +1 -0
- package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.d.ts +12 -2
- package/lib/cjs/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.js +16 -7
- 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 +31 -21
- package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetManager.js +2 -4
- package/lib/cjs/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js +4 -2
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/StreamedResponseGenerator.js +1 -0
- 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 +142 -126
- 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 +21 -19
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts +3 -0
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js +4 -0
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.d.ts +1 -0
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js +1 -0
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts +4 -0
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js +3 -0
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts +5 -2
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js +35 -13
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts +2 -0
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js +2 -0
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts +27 -7
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js +192 -87
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts +3 -7
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js +6 -11
- 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 +11 -9
- 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 +2 -1
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.js +1 -0
- package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.d.ts +12 -2
- package/lib/esm/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.js +16 -7
- 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 +32 -22
- package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetManager.js +2 -4
- package/lib/esm/presentation-frontend/RulesetManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js +4 -2
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/StreamedResponseGenerator.js +1 -0
- 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 +143 -127
- 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 +22 -20
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts +3 -0
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js +4 -0
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.d.ts +1 -0
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js +1 -0
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts +4 -0
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js +3 -0
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts +5 -2
- package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js +35 -13
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts +2 -0
- package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js +2 -0
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts +27 -7
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.js +193 -88
- package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts +3 -7
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +6 -10
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/esm/presentation-frontend.js.map +1 -1
- package/package.json +25 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionHandler.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHandler.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"SelectionHandler.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHandler.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG,qDAAqD;AACrD;;GAEG;;;AAEH,sDAAqD;AAkCrD;;;;;;GAMG;AACH,MAAa,gBAAgB;IAC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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;AAnID,4CAmIC","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/* eslint-disable @typescript-eslint/no-deprecated */\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 * @deprecated in 5.0. Use `SelectionStorage` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#basic-usage) package instead.\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 * @deprecated in 5.0. Use `SelectionStorage` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#basic-usage) package instead.\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"]}
|
|
@@ -5,6 +5,8 @@ import { Key, Keys } from "@itwin/presentation-common";
|
|
|
5
5
|
/**
|
|
6
6
|
* Helper class for working with selection.
|
|
7
7
|
* @public
|
|
8
|
+
* @deprecated in 5.0. This is unnecessary after switching to [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md)
|
|
9
|
+
* package. A similar method to this in the new system is `Selectables.load()`.
|
|
8
10
|
*/
|
|
9
11
|
export declare class SelectionHelper {
|
|
10
12
|
private constructor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionHelper.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAW,MAAM,4BAA4B,CAAC;AAEhE
|
|
1
|
+
{"version":3,"file":"SelectionHelper.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAW,MAAM,4BAA4B,CAAC;AAEhE;;;;;GAKG;AACH,qBAAa,eAAe;IAE1B,OAAO;IAEP;;;;OAIG;WACW,mBAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,GAAG,EAAE;CAe/D"}
|
|
@@ -12,6 +12,8 @@ const presentation_common_1 = require("@itwin/presentation-common");
|
|
|
12
12
|
/**
|
|
13
13
|
* Helper class for working with selection.
|
|
14
14
|
* @public
|
|
15
|
+
* @deprecated in 5.0. This is unnecessary after switching to [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md)
|
|
16
|
+
* package. A similar method to this in the new system is `Selectables.load()`.
|
|
15
17
|
*/
|
|
16
18
|
class SelectionHelper {
|
|
17
19
|
// istanbul ignore next
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionHelper.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,oEAAgE;AAEhE
|
|
1
|
+
{"version":3,"file":"SelectionHelper.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,oEAAgE;AAEhE;;;;;GAKG;AACH,MAAa,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,yBAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;gBACvB,IAAI,6BAAO,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;AAxBD,0CAwBC","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 * @deprecated in 5.0. This is unnecessary after switching to [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md)\n * package. A similar method to this in the new system is `Selectables.load()`.\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";
|
|
@@ -12,6 +12,7 @@ import { SelectionScopesManager } from "./SelectionScopesManager";
|
|
|
12
12
|
/**
|
|
13
13
|
* Properties for creating [[SelectionManager]].
|
|
14
14
|
* @public
|
|
15
|
+
* @deprecated in 5.0. Use `SelectionStorage` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.
|
|
15
16
|
*/
|
|
16
17
|
export interface SelectionManagerProps {
|
|
17
18
|
/** A manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */
|
|
@@ -21,13 +22,22 @@ export interface SelectionManagerProps {
|
|
|
21
22
|
* and maintains storage.
|
|
22
23
|
*/
|
|
23
24
|
selectionStorage?: SelectionStorage;
|
|
25
|
+
/**
|
|
26
|
+
* An optional function that returns a key for the given iModel. The key is what "glues" iModel selection
|
|
27
|
+
* changes made in `selectionStorage`, where iModels are identified by key, and `SelectionManager`, where
|
|
28
|
+
* iModels are specified as `IModelConnection`.
|
|
29
|
+
*
|
|
30
|
+
* If not provided, [IModelConnection.key]($core-frontend) or [IModelConnection.name]($core-frontend) is used.
|
|
31
|
+
*/
|
|
32
|
+
imodelKeyFactory?: (imodel: IModelConnection) => string;
|
|
24
33
|
}
|
|
25
34
|
/**
|
|
26
35
|
* The selection manager which stores the overall selection.
|
|
27
36
|
* @public
|
|
37
|
+
* @deprecated in 5.0. Use `SelectionStorage` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.
|
|
28
38
|
*/
|
|
29
|
-
export declare class SelectionManager implements ISelectionProvider {
|
|
30
|
-
private
|
|
39
|
+
export declare class SelectionManager implements ISelectionProvider, Disposable {
|
|
40
|
+
private _imodelKeyFactory;
|
|
31
41
|
private _imodelToolSelectionSyncHandlers;
|
|
32
42
|
private _hiliteSetProviders;
|
|
33
43
|
private _ownsStorage;
|
|
@@ -36,6 +46,11 @@ export declare class SelectionManager implements ISelectionProvider {
|
|
|
36
46
|
private _selectionChanges;
|
|
37
47
|
private _selectionEventsSubscription;
|
|
38
48
|
private _listeners;
|
|
49
|
+
/**
|
|
50
|
+
* Underlying selection storage used by this selection manager. Ideally, consumers should use
|
|
51
|
+
* the storage directly instead of using this manager to manipulate selection.
|
|
52
|
+
*/
|
|
53
|
+
readonly selectionStorage: SelectionStorage;
|
|
39
54
|
/** An event which gets broadcasted on selection changes */
|
|
40
55
|
readonly selectionChange: SelectionChangeEvent;
|
|
41
56
|
/** Manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */
|
|
@@ -44,6 +59,8 @@ export declare class SelectionManager implements ISelectionProvider {
|
|
|
44
59
|
* Creates an instance of SelectionManager.
|
|
45
60
|
*/
|
|
46
61
|
constructor(props: SelectionManagerProps);
|
|
62
|
+
[Symbol.dispose](): void;
|
|
63
|
+
/** @deprecated in 5.0. Use [Symbol.dispose] instead. */
|
|
47
64
|
dispose(): void;
|
|
48
65
|
private onConnectionClose;
|
|
49
66
|
/** @internal */
|
|
@@ -53,10 +70,13 @@ export declare class SelectionManager implements ISelectionProvider {
|
|
|
53
70
|
*/
|
|
54
71
|
setSyncWithIModelToolSelection(imodel: IModelConnection, sync?: boolean): void;
|
|
55
72
|
/**
|
|
56
|
-
* Temporarily suspends tool selection synchronization until the returned `
|
|
73
|
+
* Temporarily suspends tool selection synchronization until the returned `Disposable`
|
|
57
74
|
* is disposed.
|
|
58
75
|
*/
|
|
59
|
-
suspendIModelToolSelectionSync(imodel: IModelConnection):
|
|
76
|
+
suspendIModelToolSelectionSync(imodel: IModelConnection): {
|
|
77
|
+
[Symbol.dispose]: () => void;
|
|
78
|
+
dispose: () => void;
|
|
79
|
+
};
|
|
60
80
|
/** Get the selection levels currently stored in this manager for the specified imodel */
|
|
61
81
|
getSelectionLevels(imodel: IModelConnection): number[];
|
|
62
82
|
/**
|
|
@@ -147,7 +167,7 @@ export declare class SelectionManager implements ISelectionProvider {
|
|
|
147
167
|
private streamSelectionEvents;
|
|
148
168
|
}
|
|
149
169
|
/** @internal */
|
|
150
|
-
export declare class ToolSelectionSyncHandler implements
|
|
170
|
+
export declare class ToolSelectionSyncHandler implements Disposable {
|
|
151
171
|
private _selectionSourceName;
|
|
152
172
|
private _logicalSelection;
|
|
153
173
|
private _imodel;
|
|
@@ -155,7 +175,7 @@ export declare class ToolSelectionSyncHandler implements IDisposable {
|
|
|
155
175
|
private _asyncsTracker;
|
|
156
176
|
isSuspended?: boolean;
|
|
157
177
|
constructor(imodel: IModelConnection, logicalSelection: SelectionManager);
|
|
158
|
-
dispose(): void;
|
|
178
|
+
[Symbol.dispose](): void;
|
|
159
179
|
/** note: used only it tests */
|
|
160
180
|
get pendingAsyncs(): Set<string>;
|
|
161
181
|
private onToolSelectionChanged;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionManager.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SelectionManager.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionManager.ts"],"names":[],"mappings":"AAKA;;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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license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
6
7
|
/** @packageDocumentation
|
|
7
8
|
* @module UnifiedSelection
|
|
8
9
|
*/
|
|
10
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
11
|
+
if (value !== null && value !== void 0) {
|
|
12
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
13
|
+
var dispose, inner;
|
|
14
|
+
if (async) {
|
|
15
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
16
|
+
dispose = value[Symbol.asyncDispose];
|
|
17
|
+
}
|
|
18
|
+
if (dispose === void 0) {
|
|
19
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
20
|
+
dispose = value[Symbol.dispose];
|
|
21
|
+
if (async) inner = dispose;
|
|
22
|
+
}
|
|
23
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
24
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
25
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
26
|
+
}
|
|
27
|
+
else if (async) {
|
|
28
|
+
env.stack.push({ async: true });
|
|
29
|
+
}
|
|
30
|
+
return value;
|
|
31
|
+
};
|
|
32
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
33
|
+
return function (env) {
|
|
34
|
+
function fail(e) {
|
|
35
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
36
|
+
env.hasError = true;
|
|
37
|
+
}
|
|
38
|
+
var r, s = 0;
|
|
39
|
+
function next() {
|
|
40
|
+
while (r = env.stack.pop()) {
|
|
41
|
+
try {
|
|
42
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
43
|
+
if (r.dispose) {
|
|
44
|
+
var result = r.dispose.call(r.value);
|
|
45
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
46
|
+
}
|
|
47
|
+
else s |= 1;
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
fail(e);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
54
|
+
if (env.hasError) throw env.error;
|
|
55
|
+
}
|
|
56
|
+
return next();
|
|
57
|
+
};
|
|
58
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
59
|
+
var e = new Error(message);
|
|
60
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
61
|
+
});
|
|
9
62
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
63
|
exports.ToolSelectionSyncHandler = exports.SelectionManager = void 0;
|
|
11
64
|
const rxjs_1 = require("rxjs");
|
|
@@ -20,42 +73,62 @@ const SelectionScopesManager_1 = require("./SelectionScopesManager");
|
|
|
20
73
|
/**
|
|
21
74
|
* The selection manager which stores the overall selection.
|
|
22
75
|
* @public
|
|
76
|
+
* @deprecated in 5.0. Use `SelectionStorage` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.
|
|
23
77
|
*/
|
|
24
78
|
class SelectionManager {
|
|
79
|
+
_imodelKeyFactory;
|
|
80
|
+
_imodelToolSelectionSyncHandlers = new Map();
|
|
81
|
+
_hiliteSetProviders = new Map();
|
|
82
|
+
_ownsStorage;
|
|
83
|
+
_knownIModels = new Set();
|
|
84
|
+
_currentSelection = new CurrentSelectionStorage();
|
|
85
|
+
_selectionChanges = new rxjs_1.Subject();
|
|
86
|
+
_selectionEventsSubscription;
|
|
87
|
+
_listeners = [];
|
|
88
|
+
/**
|
|
89
|
+
* Underlying selection storage used by this selection manager. Ideally, consumers should use
|
|
90
|
+
* the storage directly instead of using this manager to manipulate selection.
|
|
91
|
+
*/
|
|
92
|
+
selectionStorage;
|
|
93
|
+
/** An event which gets broadcasted on selection changes */
|
|
94
|
+
selectionChange;
|
|
95
|
+
/** Manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */
|
|
96
|
+
scopes;
|
|
25
97
|
/**
|
|
26
98
|
* Creates an instance of SelectionManager.
|
|
27
99
|
*/
|
|
28
100
|
constructor(props) {
|
|
29
|
-
this._imodelToolSelectionSyncHandlers = new Map();
|
|
30
|
-
this._hiliteSetProviders = new Map();
|
|
31
|
-
this._knownIModels = new Map();
|
|
32
|
-
this._currentSelection = new CurrentSelectionStorage();
|
|
33
|
-
this._selectionChanges = new rxjs_1.Subject();
|
|
34
|
-
this._listeners = [];
|
|
35
101
|
this.selectionChange = new SelectionChangeEvent_1.SelectionChangeEvent();
|
|
36
102
|
this.scopes = props.scopes;
|
|
37
|
-
this.
|
|
103
|
+
this.selectionStorage = props.selectionStorage ?? (0, unified_selection_1.createStorage)();
|
|
104
|
+
this._imodelKeyFactory = props.imodelKeyFactory ?? ((imodel) => (imodel.key.length ? imodel.key : imodel.name));
|
|
38
105
|
this._ownsStorage = props.selectionStorage === undefined;
|
|
39
|
-
this.
|
|
106
|
+
this.selectionStorage.selectionChangeEvent.addListener((args) => this._selectionChanges.next(args));
|
|
40
107
|
this._selectionEventsSubscription = this.streamSelectionEvents();
|
|
41
108
|
this._listeners.push(core_frontend_1.IModelConnection.onOpen.addListener((imodel) => {
|
|
42
|
-
this._knownIModels.
|
|
109
|
+
this._knownIModels.add(imodel);
|
|
43
110
|
}));
|
|
44
111
|
this._listeners.push(core_frontend_1.IModelConnection.onClose.addListener((imodel) => {
|
|
45
112
|
this.onConnectionClose(imodel);
|
|
46
113
|
}));
|
|
47
114
|
}
|
|
48
|
-
dispose() {
|
|
115
|
+
[Symbol.dispose]() {
|
|
49
116
|
this._selectionEventsSubscription.unsubscribe();
|
|
50
117
|
this._listeners.forEach((dispose) => dispose());
|
|
51
118
|
}
|
|
119
|
+
/** @deprecated in 5.0. Use [Symbol.dispose] instead. */
|
|
120
|
+
// istanbul ignore next
|
|
121
|
+
dispose() {
|
|
122
|
+
this[Symbol.dispose]();
|
|
123
|
+
}
|
|
52
124
|
onConnectionClose(imodel) {
|
|
125
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
53
126
|
this._hiliteSetProviders.delete(imodel);
|
|
54
|
-
this._knownIModels.delete(imodel
|
|
55
|
-
this._currentSelection.clear(
|
|
127
|
+
this._knownIModels.delete(imodel);
|
|
128
|
+
this._currentSelection.clear(imodelKey);
|
|
56
129
|
if (this._ownsStorage) {
|
|
57
130
|
this.clearSelection("Connection Close Event", imodel);
|
|
58
|
-
this.
|
|
131
|
+
this.selectionStorage.clearStorage({ imodelKey });
|
|
59
132
|
}
|
|
60
133
|
}
|
|
61
134
|
/** @internal */
|
|
@@ -84,27 +157,30 @@ class SelectionManager {
|
|
|
84
157
|
}
|
|
85
158
|
else {
|
|
86
159
|
this._imodelToolSelectionSyncHandlers.delete(imodel);
|
|
87
|
-
registration.handler.dispose();
|
|
160
|
+
registration.handler[Symbol.dispose]();
|
|
88
161
|
}
|
|
89
162
|
}
|
|
90
163
|
}
|
|
91
164
|
}
|
|
92
165
|
/**
|
|
93
|
-
* Temporarily suspends tool selection synchronization until the returned `
|
|
166
|
+
* Temporarily suspends tool selection synchronization until the returned `Disposable`
|
|
94
167
|
* is disposed.
|
|
95
168
|
*/
|
|
96
169
|
suspendIModelToolSelectionSync(imodel) {
|
|
97
170
|
const registration = this._imodelToolSelectionSyncHandlers.get(imodel);
|
|
98
171
|
if (!registration) {
|
|
99
|
-
|
|
172
|
+
const noop = () => { };
|
|
173
|
+
return { [Symbol.dispose]: noop, dispose: noop };
|
|
100
174
|
}
|
|
101
175
|
const wasSuspended = registration.handler.isSuspended;
|
|
102
176
|
registration.handler.isSuspended = true;
|
|
103
|
-
|
|
177
|
+
const doDispose = () => (registration.handler.isSuspended = wasSuspended);
|
|
178
|
+
return { [Symbol.dispose]: doDispose, dispose: doDispose };
|
|
104
179
|
}
|
|
105
180
|
/** Get the selection levels currently stored in this manager for the specified imodel */
|
|
106
181
|
getSelectionLevels(imodel) {
|
|
107
|
-
|
|
182
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
183
|
+
return this.selectionStorage.getSelectionLevels({ imodelKey });
|
|
108
184
|
}
|
|
109
185
|
/**
|
|
110
186
|
* Get the selection currently stored in this manager
|
|
@@ -114,39 +190,39 @@ class SelectionManager {
|
|
|
114
190
|
* latest selection after changes.
|
|
115
191
|
*/
|
|
116
192
|
getSelection(imodel, level = 0) {
|
|
117
|
-
|
|
193
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
194
|
+
return this._currentSelection.getSelection(imodelKey, level);
|
|
118
195
|
}
|
|
119
196
|
handleEvent(evt) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
197
|
+
const imodelKey = this._imodelKeyFactory(evt.imodel);
|
|
198
|
+
this._knownIModels.add(evt.imodel);
|
|
123
199
|
switch (evt.changeType) {
|
|
124
200
|
case SelectionChangeEvent_1.SelectionChangeType.Add:
|
|
125
|
-
this.
|
|
126
|
-
|
|
201
|
+
this.selectionStorage.addToSelection({
|
|
202
|
+
imodelKey,
|
|
127
203
|
source: evt.source,
|
|
128
204
|
level: evt.level,
|
|
129
205
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
130
206
|
});
|
|
131
207
|
break;
|
|
132
208
|
case SelectionChangeEvent_1.SelectionChangeType.Remove:
|
|
133
|
-
this.
|
|
134
|
-
|
|
209
|
+
this.selectionStorage.removeFromSelection({
|
|
210
|
+
imodelKey,
|
|
135
211
|
source: evt.source,
|
|
136
212
|
level: evt.level,
|
|
137
213
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
138
214
|
});
|
|
139
215
|
break;
|
|
140
216
|
case SelectionChangeEvent_1.SelectionChangeType.Replace:
|
|
141
|
-
this.
|
|
142
|
-
|
|
217
|
+
this.selectionStorage.replaceSelection({
|
|
218
|
+
imodelKey,
|
|
143
219
|
source: evt.source,
|
|
144
220
|
level: evt.level,
|
|
145
221
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
146
222
|
});
|
|
147
223
|
break;
|
|
148
224
|
case SelectionChangeEvent_1.SelectionChangeType.Clear:
|
|
149
|
-
this.
|
|
225
|
+
this.selectionStorage.clearSelection({ imodelKey, source: evt.source, level: evt.level });
|
|
150
226
|
break;
|
|
151
227
|
}
|
|
152
228
|
}
|
|
@@ -293,9 +369,9 @@ class SelectionManager {
|
|
|
293
369
|
streamSelectionEvents() {
|
|
294
370
|
return this._selectionChanges
|
|
295
371
|
.pipe((0, rxjs_1.mergeMap)((args) => {
|
|
296
|
-
const currentSelectables = this.
|
|
372
|
+
const currentSelectables = this.selectionStorage.getSelection({ imodelKey: args.imodelKey, level: args.level });
|
|
297
373
|
return this._currentSelection.computeSelection(args.imodelKey, args.level, currentSelectables, args.selectables).pipe((0, rxjs_1.mergeMap)(({ level, changedSelection }) => {
|
|
298
|
-
const imodel = this._knownIModels.
|
|
374
|
+
const imodel = findIModel(this._knownIModels, this._imodelKeyFactory, args.imodelKey);
|
|
299
375
|
// istanbul ignore if
|
|
300
376
|
if (!imodel) {
|
|
301
377
|
return rxjs_1.EMPTY;
|
|
@@ -318,12 +394,37 @@ class SelectionManager {
|
|
|
318
394
|
}
|
|
319
395
|
}
|
|
320
396
|
exports.SelectionManager = SelectionManager;
|
|
397
|
+
function findIModel(set, imodelKeyFactory, key) {
|
|
398
|
+
for (const imodel of set) {
|
|
399
|
+
if (imodelKeyFactory(imodel) === key) {
|
|
400
|
+
return imodel;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return undefined;
|
|
404
|
+
}
|
|
321
405
|
/** @internal */
|
|
322
406
|
class ToolSelectionSyncHandler {
|
|
407
|
+
_selectionSourceName = "Tool";
|
|
408
|
+
_logicalSelection;
|
|
409
|
+
_imodel;
|
|
410
|
+
_imodelToolSelectionListenerDisposeFunc;
|
|
411
|
+
_asyncsTracker = new presentation_common_1.AsyncTasksTracker();
|
|
412
|
+
isSuspended;
|
|
323
413
|
constructor(imodel, logicalSelection) {
|
|
324
|
-
this.
|
|
325
|
-
this.
|
|
326
|
-
this.
|
|
414
|
+
this._imodel = imodel;
|
|
415
|
+
this._logicalSelection = logicalSelection;
|
|
416
|
+
this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);
|
|
417
|
+
}
|
|
418
|
+
[Symbol.dispose]() {
|
|
419
|
+
this._imodelToolSelectionListenerDisposeFunc();
|
|
420
|
+
}
|
|
421
|
+
/** note: used only it tests */
|
|
422
|
+
get pendingAsyncs() {
|
|
423
|
+
return this._asyncsTracker.pendingAsyncs;
|
|
424
|
+
}
|
|
425
|
+
onToolSelectionChanged = async (ev) => {
|
|
426
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
427
|
+
try {
|
|
327
428
|
// ignore selection change event if the handler is suspended
|
|
328
429
|
if (this.isSuspended) {
|
|
329
430
|
return;
|
|
@@ -339,13 +440,13 @@ class ToolSelectionSyncHandler {
|
|
|
339
440
|
let ids;
|
|
340
441
|
switch (ev.type) {
|
|
341
442
|
case core_frontend_1.SelectionSetEventType.Add:
|
|
342
|
-
ids = ev.
|
|
443
|
+
ids = ev.additions;
|
|
343
444
|
break;
|
|
344
445
|
case core_frontend_1.SelectionSetEventType.Replace:
|
|
345
|
-
ids = ev.set.
|
|
446
|
+
ids = ev.set.active;
|
|
346
447
|
break;
|
|
347
448
|
default:
|
|
348
|
-
ids = ev.
|
|
449
|
+
ids = ev.removals;
|
|
349
450
|
break;
|
|
350
451
|
}
|
|
351
452
|
// we're always using scoped selection changer even if the scope is set to "element" - that
|
|
@@ -353,40 +454,33 @@ class ToolSelectionSyncHandler {
|
|
|
353
454
|
// we can't because otherwise our keys compare fails (presentation components load data with
|
|
354
455
|
// concrete classes)
|
|
355
456
|
const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, (0, SelectionScopesManager_1.createSelectionScopeProps)(this._logicalSelection.scopes.activeScope));
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
457
|
+
const _r = __addDisposableResource(env_1, this._asyncsTracker.trackAsyncTask(), false);
|
|
458
|
+
switch (ev.type) {
|
|
459
|
+
case core_frontend_1.SelectionSetEventType.Add:
|
|
460
|
+
await changer.add(ids, selectionLevel);
|
|
461
|
+
break;
|
|
462
|
+
case core_frontend_1.SelectionSetEventType.Replace:
|
|
463
|
+
await changer.replace(ids, selectionLevel);
|
|
464
|
+
break;
|
|
465
|
+
case core_frontend_1.SelectionSetEventType.Remove:
|
|
466
|
+
await changer.remove(ids, selectionLevel);
|
|
467
|
+
break;
|
|
468
|
+
case core_frontend_1.SelectionSetEventType.Clear:
|
|
469
|
+
await changer.clear(selectionLevel);
|
|
470
|
+
break;
|
|
360
471
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
case core_frontend_1.SelectionSetEventType.Remove:
|
|
371
|
-
await changer.remove(parsedIds.transient, parsedIds.persistent, selectionLevel);
|
|
372
|
-
break;
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
};
|
|
376
|
-
this._imodel = imodel;
|
|
377
|
-
this._logicalSelection = logicalSelection;
|
|
378
|
-
this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);
|
|
379
|
-
}
|
|
380
|
-
dispose() {
|
|
381
|
-
this._imodelToolSelectionListenerDisposeFunc();
|
|
382
|
-
}
|
|
383
|
-
/** note: used only it tests */
|
|
384
|
-
get pendingAsyncs() {
|
|
385
|
-
return this._asyncsTracker.pendingAsyncs;
|
|
386
|
-
}
|
|
472
|
+
}
|
|
473
|
+
catch (e_1) {
|
|
474
|
+
env_1.error = e_1;
|
|
475
|
+
env_1.hasError = true;
|
|
476
|
+
}
|
|
477
|
+
finally {
|
|
478
|
+
__disposeResources(env_1);
|
|
479
|
+
}
|
|
480
|
+
};
|
|
387
481
|
}
|
|
388
482
|
exports.ToolSelectionSyncHandler = ToolSelectionSyncHandler;
|
|
389
|
-
const
|
|
483
|
+
const parseElementIds = (ids) => {
|
|
390
484
|
let allPersistent = true;
|
|
391
485
|
let allTransient = true;
|
|
392
486
|
for (const id of core_bentley_1.Id64.iterable(ids)) {
|
|
@@ -421,13 +515,16 @@ const parseIds = (ids) => {
|
|
|
421
515
|
}
|
|
422
516
|
return { persistent: persistentElementIds, transient: transientElementIds };
|
|
423
517
|
};
|
|
424
|
-
function
|
|
425
|
-
for (const id of core_bentley_1.Id64.iterable(
|
|
426
|
-
|
|
518
|
+
function addKeys(target, className, ids) {
|
|
519
|
+
for (const id of core_bentley_1.Id64.iterable(ids)) {
|
|
520
|
+
target.add({ className, id });
|
|
427
521
|
}
|
|
428
522
|
}
|
|
429
|
-
/** @internal */
|
|
430
523
|
class ScopedSelectionChanger {
|
|
524
|
+
name;
|
|
525
|
+
imodel;
|
|
526
|
+
manager;
|
|
527
|
+
scope;
|
|
431
528
|
constructor(name, imodel, manager, scope) {
|
|
432
529
|
this.name = name;
|
|
433
530
|
this.imodel = imodel;
|
|
@@ -437,27 +534,37 @@ class ScopedSelectionChanger {
|
|
|
437
534
|
async clear(level) {
|
|
438
535
|
this.manager.clearSelection(this.name, this.imodel, level);
|
|
439
536
|
}
|
|
440
|
-
async add(
|
|
441
|
-
const keys = await this
|
|
442
|
-
addTransientKeys(transientIds, keys);
|
|
537
|
+
async add(ids, level) {
|
|
538
|
+
const keys = await this.#computeSelection(ids);
|
|
443
539
|
this.manager.addToSelection(this.name, this.imodel, keys, level);
|
|
444
540
|
}
|
|
445
|
-
async remove(
|
|
446
|
-
const keys = await this
|
|
447
|
-
addTransientKeys(transientIds, keys);
|
|
541
|
+
async remove(ids, level) {
|
|
542
|
+
const keys = await this.#computeSelection(ids);
|
|
448
543
|
this.manager.removeFromSelection(this.name, this.imodel, keys, level);
|
|
449
544
|
}
|
|
450
|
-
async replace(
|
|
451
|
-
const keys = await this
|
|
452
|
-
addTransientKeys(transientIds, keys);
|
|
545
|
+
async replace(ids, level) {
|
|
546
|
+
const keys = await this.#computeSelection(ids);
|
|
453
547
|
this.manager.replaceSelection(this.name, this.imodel, keys, level);
|
|
454
548
|
}
|
|
549
|
+
async #computeSelection(ids) {
|
|
550
|
+
let keys = new presentation_common_1.KeySet();
|
|
551
|
+
if (ids.elements) {
|
|
552
|
+
const { persistent, transient } = parseElementIds(ids.elements);
|
|
553
|
+
keys = await this.manager.scopes.computeSelection(this.imodel, persistent, this.scope);
|
|
554
|
+
addKeys(keys, unified_selection_1.TRANSIENT_ELEMENT_CLASSNAME, transient);
|
|
555
|
+
}
|
|
556
|
+
if (ids.models) {
|
|
557
|
+
addKeys(keys, "BisCore.Model", ids.models);
|
|
558
|
+
}
|
|
559
|
+
if (ids.subcategories) {
|
|
560
|
+
addKeys(keys, "BisCore.SubCategory", ids.subcategories);
|
|
561
|
+
}
|
|
562
|
+
return keys;
|
|
563
|
+
}
|
|
455
564
|
}
|
|
456
565
|
/** Stores current selection in `KeySet` format per iModel. */
|
|
457
566
|
class CurrentSelectionStorage {
|
|
458
|
-
|
|
459
|
-
this._currentSelection = new Map();
|
|
460
|
-
}
|
|
567
|
+
_currentSelection = new Map();
|
|
461
568
|
getCurrentSelectionStorage(imodelKey) {
|
|
462
569
|
let storage = this._currentSelection.get(imodelKey);
|
|
463
570
|
if (!storage) {
|
|
@@ -481,9 +588,7 @@ class CurrentSelectionStorage {
|
|
|
481
588
|
* It always stores result of latest resolved call to `computeSelection`.
|
|
482
589
|
*/
|
|
483
590
|
class IModelSelectionStorage {
|
|
484
|
-
|
|
485
|
-
this._currentSelection = new Map();
|
|
486
|
-
}
|
|
591
|
+
_currentSelection = new Map();
|
|
487
592
|
getSelection(level) {
|
|
488
593
|
let entry = this._currentSelection.get(level);
|
|
489
594
|
if (!entry) {
|