@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
|
@@ -2,11 +2,64 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
5
6
|
/** @packageDocumentation
|
|
6
7
|
* @module UnifiedSelection
|
|
7
8
|
*/
|
|
9
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
10
|
+
if (value !== null && value !== void 0) {
|
|
11
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
12
|
+
var dispose, inner;
|
|
13
|
+
if (async) {
|
|
14
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
15
|
+
dispose = value[Symbol.asyncDispose];
|
|
16
|
+
}
|
|
17
|
+
if (dispose === void 0) {
|
|
18
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
19
|
+
dispose = value[Symbol.dispose];
|
|
20
|
+
if (async) inner = dispose;
|
|
21
|
+
}
|
|
22
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
23
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
24
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
25
|
+
}
|
|
26
|
+
else if (async) {
|
|
27
|
+
env.stack.push({ async: true });
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
31
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
32
|
+
return function (env) {
|
|
33
|
+
function fail(e) {
|
|
34
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
35
|
+
env.hasError = true;
|
|
36
|
+
}
|
|
37
|
+
var r, s = 0;
|
|
38
|
+
function next() {
|
|
39
|
+
while (r = env.stack.pop()) {
|
|
40
|
+
try {
|
|
41
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
42
|
+
if (r.dispose) {
|
|
43
|
+
var result = r.dispose.call(r.value);
|
|
44
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
45
|
+
}
|
|
46
|
+
else s |= 1;
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
fail(e);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
53
|
+
if (env.hasError) throw env.error;
|
|
54
|
+
}
|
|
55
|
+
return next();
|
|
56
|
+
};
|
|
57
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
58
|
+
var e = new Error(message);
|
|
59
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
60
|
+
});
|
|
8
61
|
import { defer, EMPTY, mergeMap, of, Subject, takeUntil, tap } from "rxjs";
|
|
9
|
-
import { Id64
|
|
62
|
+
import { Id64 } from "@itwin/core-bentley";
|
|
10
63
|
import { IModelConnection, SelectionSetEventType } from "@itwin/core-frontend";
|
|
11
64
|
import { AsyncTasksTracker, KeySet, NodeKey } from "@itwin/presentation-common";
|
|
12
65
|
import { createStorage, TRANSIENT_ELEMENT_CLASSNAME, } from "@itwin/unified-selection";
|
|
@@ -17,42 +70,62 @@ import { createSelectionScopeProps } from "./SelectionScopesManager";
|
|
|
17
70
|
/**
|
|
18
71
|
* The selection manager which stores the overall selection.
|
|
19
72
|
* @public
|
|
73
|
+
* @deprecated in 5.0. Use `SelectionStorage` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md) package instead.
|
|
20
74
|
*/
|
|
21
75
|
export class SelectionManager {
|
|
76
|
+
_imodelKeyFactory;
|
|
77
|
+
_imodelToolSelectionSyncHandlers = new Map();
|
|
78
|
+
_hiliteSetProviders = new Map();
|
|
79
|
+
_ownsStorage;
|
|
80
|
+
_knownIModels = new Set();
|
|
81
|
+
_currentSelection = new CurrentSelectionStorage();
|
|
82
|
+
_selectionChanges = new Subject();
|
|
83
|
+
_selectionEventsSubscription;
|
|
84
|
+
_listeners = [];
|
|
85
|
+
/**
|
|
86
|
+
* Underlying selection storage used by this selection manager. Ideally, consumers should use
|
|
87
|
+
* the storage directly instead of using this manager to manipulate selection.
|
|
88
|
+
*/
|
|
89
|
+
selectionStorage;
|
|
90
|
+
/** An event which gets broadcasted on selection changes */
|
|
91
|
+
selectionChange;
|
|
92
|
+
/** Manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */
|
|
93
|
+
scopes;
|
|
22
94
|
/**
|
|
23
95
|
* Creates an instance of SelectionManager.
|
|
24
96
|
*/
|
|
25
97
|
constructor(props) {
|
|
26
|
-
this._imodelToolSelectionSyncHandlers = new Map();
|
|
27
|
-
this._hiliteSetProviders = new Map();
|
|
28
|
-
this._knownIModels = new Map();
|
|
29
|
-
this._currentSelection = new CurrentSelectionStorage();
|
|
30
|
-
this._selectionChanges = new Subject();
|
|
31
|
-
this._listeners = [];
|
|
32
98
|
this.selectionChange = new SelectionChangeEvent();
|
|
33
99
|
this.scopes = props.scopes;
|
|
34
|
-
this.
|
|
100
|
+
this.selectionStorage = props.selectionStorage ?? createStorage();
|
|
101
|
+
this._imodelKeyFactory = props.imodelKeyFactory ?? ((imodel) => (imodel.key.length ? imodel.key : imodel.name));
|
|
35
102
|
this._ownsStorage = props.selectionStorage === undefined;
|
|
36
|
-
this.
|
|
103
|
+
this.selectionStorage.selectionChangeEvent.addListener((args) => this._selectionChanges.next(args));
|
|
37
104
|
this._selectionEventsSubscription = this.streamSelectionEvents();
|
|
38
105
|
this._listeners.push(IModelConnection.onOpen.addListener((imodel) => {
|
|
39
|
-
this._knownIModels.
|
|
106
|
+
this._knownIModels.add(imodel);
|
|
40
107
|
}));
|
|
41
108
|
this._listeners.push(IModelConnection.onClose.addListener((imodel) => {
|
|
42
109
|
this.onConnectionClose(imodel);
|
|
43
110
|
}));
|
|
44
111
|
}
|
|
45
|
-
dispose() {
|
|
112
|
+
[Symbol.dispose]() {
|
|
46
113
|
this._selectionEventsSubscription.unsubscribe();
|
|
47
114
|
this._listeners.forEach((dispose) => dispose());
|
|
48
115
|
}
|
|
116
|
+
/** @deprecated in 5.0. Use [Symbol.dispose] instead. */
|
|
117
|
+
// istanbul ignore next
|
|
118
|
+
dispose() {
|
|
119
|
+
this[Symbol.dispose]();
|
|
120
|
+
}
|
|
49
121
|
onConnectionClose(imodel) {
|
|
122
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
50
123
|
this._hiliteSetProviders.delete(imodel);
|
|
51
|
-
this._knownIModels.delete(imodel
|
|
52
|
-
this._currentSelection.clear(
|
|
124
|
+
this._knownIModels.delete(imodel);
|
|
125
|
+
this._currentSelection.clear(imodelKey);
|
|
53
126
|
if (this._ownsStorage) {
|
|
54
127
|
this.clearSelection("Connection Close Event", imodel);
|
|
55
|
-
this.
|
|
128
|
+
this.selectionStorage.clearStorage({ imodelKey });
|
|
56
129
|
}
|
|
57
130
|
}
|
|
58
131
|
/** @internal */
|
|
@@ -81,27 +154,30 @@ export class SelectionManager {
|
|
|
81
154
|
}
|
|
82
155
|
else {
|
|
83
156
|
this._imodelToolSelectionSyncHandlers.delete(imodel);
|
|
84
|
-
registration.handler.dispose();
|
|
157
|
+
registration.handler[Symbol.dispose]();
|
|
85
158
|
}
|
|
86
159
|
}
|
|
87
160
|
}
|
|
88
161
|
}
|
|
89
162
|
/**
|
|
90
|
-
* Temporarily suspends tool selection synchronization until the returned `
|
|
163
|
+
* Temporarily suspends tool selection synchronization until the returned `Disposable`
|
|
91
164
|
* is disposed.
|
|
92
165
|
*/
|
|
93
166
|
suspendIModelToolSelectionSync(imodel) {
|
|
94
167
|
const registration = this._imodelToolSelectionSyncHandlers.get(imodel);
|
|
95
168
|
if (!registration) {
|
|
96
|
-
|
|
169
|
+
const noop = () => { };
|
|
170
|
+
return { [Symbol.dispose]: noop, dispose: noop };
|
|
97
171
|
}
|
|
98
172
|
const wasSuspended = registration.handler.isSuspended;
|
|
99
173
|
registration.handler.isSuspended = true;
|
|
100
|
-
|
|
174
|
+
const doDispose = () => (registration.handler.isSuspended = wasSuspended);
|
|
175
|
+
return { [Symbol.dispose]: doDispose, dispose: doDispose };
|
|
101
176
|
}
|
|
102
177
|
/** Get the selection levels currently stored in this manager for the specified imodel */
|
|
103
178
|
getSelectionLevels(imodel) {
|
|
104
|
-
|
|
179
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
180
|
+
return this.selectionStorage.getSelectionLevels({ imodelKey });
|
|
105
181
|
}
|
|
106
182
|
/**
|
|
107
183
|
* Get the selection currently stored in this manager
|
|
@@ -111,39 +187,39 @@ export class SelectionManager {
|
|
|
111
187
|
* latest selection after changes.
|
|
112
188
|
*/
|
|
113
189
|
getSelection(imodel, level = 0) {
|
|
114
|
-
|
|
190
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
191
|
+
return this._currentSelection.getSelection(imodelKey, level);
|
|
115
192
|
}
|
|
116
193
|
handleEvent(evt) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
194
|
+
const imodelKey = this._imodelKeyFactory(evt.imodel);
|
|
195
|
+
this._knownIModels.add(evt.imodel);
|
|
120
196
|
switch (evt.changeType) {
|
|
121
197
|
case SelectionChangeType.Add:
|
|
122
|
-
this.
|
|
123
|
-
|
|
198
|
+
this.selectionStorage.addToSelection({
|
|
199
|
+
imodelKey,
|
|
124
200
|
source: evt.source,
|
|
125
201
|
level: evt.level,
|
|
126
202
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
127
203
|
});
|
|
128
204
|
break;
|
|
129
205
|
case SelectionChangeType.Remove:
|
|
130
|
-
this.
|
|
131
|
-
|
|
206
|
+
this.selectionStorage.removeFromSelection({
|
|
207
|
+
imodelKey,
|
|
132
208
|
source: evt.source,
|
|
133
209
|
level: evt.level,
|
|
134
210
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
135
211
|
});
|
|
136
212
|
break;
|
|
137
213
|
case SelectionChangeType.Replace:
|
|
138
|
-
this.
|
|
139
|
-
|
|
214
|
+
this.selectionStorage.replaceSelection({
|
|
215
|
+
imodelKey,
|
|
140
216
|
source: evt.source,
|
|
141
217
|
level: evt.level,
|
|
142
218
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
143
219
|
});
|
|
144
220
|
break;
|
|
145
221
|
case SelectionChangeType.Clear:
|
|
146
|
-
this.
|
|
222
|
+
this.selectionStorage.clearSelection({ imodelKey, source: evt.source, level: evt.level });
|
|
147
223
|
break;
|
|
148
224
|
}
|
|
149
225
|
}
|
|
@@ -290,9 +366,9 @@ export class SelectionManager {
|
|
|
290
366
|
streamSelectionEvents() {
|
|
291
367
|
return this._selectionChanges
|
|
292
368
|
.pipe(mergeMap((args) => {
|
|
293
|
-
const currentSelectables = this.
|
|
369
|
+
const currentSelectables = this.selectionStorage.getSelection({ imodelKey: args.imodelKey, level: args.level });
|
|
294
370
|
return this._currentSelection.computeSelection(args.imodelKey, args.level, currentSelectables, args.selectables).pipe(mergeMap(({ level, changedSelection }) => {
|
|
295
|
-
const imodel = this._knownIModels.
|
|
371
|
+
const imodel = findIModel(this._knownIModels, this._imodelKeyFactory, args.imodelKey);
|
|
296
372
|
// istanbul ignore if
|
|
297
373
|
if (!imodel) {
|
|
298
374
|
return EMPTY;
|
|
@@ -314,12 +390,37 @@ export class SelectionManager {
|
|
|
314
390
|
});
|
|
315
391
|
}
|
|
316
392
|
}
|
|
393
|
+
function findIModel(set, imodelKeyFactory, key) {
|
|
394
|
+
for (const imodel of set) {
|
|
395
|
+
if (imodelKeyFactory(imodel) === key) {
|
|
396
|
+
return imodel;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return undefined;
|
|
400
|
+
}
|
|
317
401
|
/** @internal */
|
|
318
402
|
export class ToolSelectionSyncHandler {
|
|
403
|
+
_selectionSourceName = "Tool";
|
|
404
|
+
_logicalSelection;
|
|
405
|
+
_imodel;
|
|
406
|
+
_imodelToolSelectionListenerDisposeFunc;
|
|
407
|
+
_asyncsTracker = new AsyncTasksTracker();
|
|
408
|
+
isSuspended;
|
|
319
409
|
constructor(imodel, logicalSelection) {
|
|
320
|
-
this.
|
|
321
|
-
this.
|
|
322
|
-
this.
|
|
410
|
+
this._imodel = imodel;
|
|
411
|
+
this._logicalSelection = logicalSelection;
|
|
412
|
+
this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);
|
|
413
|
+
}
|
|
414
|
+
[Symbol.dispose]() {
|
|
415
|
+
this._imodelToolSelectionListenerDisposeFunc();
|
|
416
|
+
}
|
|
417
|
+
/** note: used only it tests */
|
|
418
|
+
get pendingAsyncs() {
|
|
419
|
+
return this._asyncsTracker.pendingAsyncs;
|
|
420
|
+
}
|
|
421
|
+
onToolSelectionChanged = async (ev) => {
|
|
422
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
423
|
+
try {
|
|
323
424
|
// ignore selection change event if the handler is suspended
|
|
324
425
|
if (this.isSuspended) {
|
|
325
426
|
return;
|
|
@@ -335,13 +436,13 @@ export class ToolSelectionSyncHandler {
|
|
|
335
436
|
let ids;
|
|
336
437
|
switch (ev.type) {
|
|
337
438
|
case SelectionSetEventType.Add:
|
|
338
|
-
ids = ev.
|
|
439
|
+
ids = ev.additions;
|
|
339
440
|
break;
|
|
340
441
|
case SelectionSetEventType.Replace:
|
|
341
|
-
ids = ev.set.
|
|
442
|
+
ids = ev.set.active;
|
|
342
443
|
break;
|
|
343
444
|
default:
|
|
344
|
-
ids = ev.
|
|
445
|
+
ids = ev.removals;
|
|
345
446
|
break;
|
|
346
447
|
}
|
|
347
448
|
// we're always using scoped selection changer even if the scope is set to "element" - that
|
|
@@ -349,39 +450,32 @@ export class ToolSelectionSyncHandler {
|
|
|
349
450
|
// we can't because otherwise our keys compare fails (presentation components load data with
|
|
350
451
|
// concrete classes)
|
|
351
452
|
const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, createSelectionScopeProps(this._logicalSelection.scopes.activeScope));
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
453
|
+
const _r = __addDisposableResource(env_1, this._asyncsTracker.trackAsyncTask(), false);
|
|
454
|
+
switch (ev.type) {
|
|
455
|
+
case SelectionSetEventType.Add:
|
|
456
|
+
await changer.add(ids, selectionLevel);
|
|
457
|
+
break;
|
|
458
|
+
case SelectionSetEventType.Replace:
|
|
459
|
+
await changer.replace(ids, selectionLevel);
|
|
460
|
+
break;
|
|
461
|
+
case SelectionSetEventType.Remove:
|
|
462
|
+
await changer.remove(ids, selectionLevel);
|
|
463
|
+
break;
|
|
464
|
+
case SelectionSetEventType.Clear:
|
|
465
|
+
await changer.clear(selectionLevel);
|
|
466
|
+
break;
|
|
356
467
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
case SelectionSetEventType.Remove:
|
|
367
|
-
await changer.remove(parsedIds.transient, parsedIds.persistent, selectionLevel);
|
|
368
|
-
break;
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
};
|
|
372
|
-
this._imodel = imodel;
|
|
373
|
-
this._logicalSelection = logicalSelection;
|
|
374
|
-
this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);
|
|
375
|
-
}
|
|
376
|
-
dispose() {
|
|
377
|
-
this._imodelToolSelectionListenerDisposeFunc();
|
|
378
|
-
}
|
|
379
|
-
/** note: used only it tests */
|
|
380
|
-
get pendingAsyncs() {
|
|
381
|
-
return this._asyncsTracker.pendingAsyncs;
|
|
382
|
-
}
|
|
468
|
+
}
|
|
469
|
+
catch (e_1) {
|
|
470
|
+
env_1.error = e_1;
|
|
471
|
+
env_1.hasError = true;
|
|
472
|
+
}
|
|
473
|
+
finally {
|
|
474
|
+
__disposeResources(env_1);
|
|
475
|
+
}
|
|
476
|
+
};
|
|
383
477
|
}
|
|
384
|
-
const
|
|
478
|
+
const parseElementIds = (ids) => {
|
|
385
479
|
let allPersistent = true;
|
|
386
480
|
let allTransient = true;
|
|
387
481
|
for (const id of Id64.iterable(ids)) {
|
|
@@ -416,13 +510,16 @@ const parseIds = (ids) => {
|
|
|
416
510
|
}
|
|
417
511
|
return { persistent: persistentElementIds, transient: transientElementIds };
|
|
418
512
|
};
|
|
419
|
-
function
|
|
420
|
-
for (const id of Id64.iterable(
|
|
421
|
-
|
|
513
|
+
function addKeys(target, className, ids) {
|
|
514
|
+
for (const id of Id64.iterable(ids)) {
|
|
515
|
+
target.add({ className, id });
|
|
422
516
|
}
|
|
423
517
|
}
|
|
424
|
-
/** @internal */
|
|
425
518
|
class ScopedSelectionChanger {
|
|
519
|
+
name;
|
|
520
|
+
imodel;
|
|
521
|
+
manager;
|
|
522
|
+
scope;
|
|
426
523
|
constructor(name, imodel, manager, scope) {
|
|
427
524
|
this.name = name;
|
|
428
525
|
this.imodel = imodel;
|
|
@@ -432,27 +529,37 @@ class ScopedSelectionChanger {
|
|
|
432
529
|
async clear(level) {
|
|
433
530
|
this.manager.clearSelection(this.name, this.imodel, level);
|
|
434
531
|
}
|
|
435
|
-
async add(
|
|
436
|
-
const keys = await this
|
|
437
|
-
addTransientKeys(transientIds, keys);
|
|
532
|
+
async add(ids, level) {
|
|
533
|
+
const keys = await this.#computeSelection(ids);
|
|
438
534
|
this.manager.addToSelection(this.name, this.imodel, keys, level);
|
|
439
535
|
}
|
|
440
|
-
async remove(
|
|
441
|
-
const keys = await this
|
|
442
|
-
addTransientKeys(transientIds, keys);
|
|
536
|
+
async remove(ids, level) {
|
|
537
|
+
const keys = await this.#computeSelection(ids);
|
|
443
538
|
this.manager.removeFromSelection(this.name, this.imodel, keys, level);
|
|
444
539
|
}
|
|
445
|
-
async replace(
|
|
446
|
-
const keys = await this
|
|
447
|
-
addTransientKeys(transientIds, keys);
|
|
540
|
+
async replace(ids, level) {
|
|
541
|
+
const keys = await this.#computeSelection(ids);
|
|
448
542
|
this.manager.replaceSelection(this.name, this.imodel, keys, level);
|
|
449
543
|
}
|
|
544
|
+
async #computeSelection(ids) {
|
|
545
|
+
let keys = new KeySet();
|
|
546
|
+
if (ids.elements) {
|
|
547
|
+
const { persistent, transient } = parseElementIds(ids.elements);
|
|
548
|
+
keys = await this.manager.scopes.computeSelection(this.imodel, persistent, this.scope);
|
|
549
|
+
addKeys(keys, TRANSIENT_ELEMENT_CLASSNAME, transient);
|
|
550
|
+
}
|
|
551
|
+
if (ids.models) {
|
|
552
|
+
addKeys(keys, "BisCore.Model", ids.models);
|
|
553
|
+
}
|
|
554
|
+
if (ids.subcategories) {
|
|
555
|
+
addKeys(keys, "BisCore.SubCategory", ids.subcategories);
|
|
556
|
+
}
|
|
557
|
+
return keys;
|
|
558
|
+
}
|
|
450
559
|
}
|
|
451
560
|
/** Stores current selection in `KeySet` format per iModel. */
|
|
452
561
|
class CurrentSelectionStorage {
|
|
453
|
-
|
|
454
|
-
this._currentSelection = new Map();
|
|
455
|
-
}
|
|
562
|
+
_currentSelection = new Map();
|
|
456
563
|
getCurrentSelectionStorage(imodelKey) {
|
|
457
564
|
let storage = this._currentSelection.get(imodelKey);
|
|
458
565
|
if (!storage) {
|
|
@@ -476,9 +583,7 @@ class CurrentSelectionStorage {
|
|
|
476
583
|
* It always stores result of latest resolved call to `computeSelection`.
|
|
477
584
|
*/
|
|
478
585
|
class IModelSelectionStorage {
|
|
479
|
-
|
|
480
|
-
this._currentSelection = new Map();
|
|
481
|
-
}
|
|
586
|
+
_currentSelection = new Map();
|
|
482
587
|
getSelection(level) {
|
|
483
588
|
let entry = this._currentSelection.get(level);
|
|
484
589
|
if (!entry) {
|