@itwin/presentation-frontend 5.0.0-dev.6 → 5.0.0-dev.61
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 +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.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 +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.js +2 -0
- 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 +33 -13
- 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 +190 -87
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js +3 -0
- 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.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 +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.js +2 -0
- 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 +33 -13
- 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 +191 -88
- package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +3 -0
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/esm/presentation-frontend.js.map +1 -1
- package/package.json +19 -18
|
@@ -6,6 +6,58 @@
|
|
|
6
6
|
/** @packageDocumentation
|
|
7
7
|
* @module UnifiedSelection
|
|
8
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
|
+
});
|
|
9
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
62
|
exports.ToolSelectionSyncHandler = exports.SelectionManager = void 0;
|
|
11
63
|
const rxjs_1 = require("rxjs");
|
|
@@ -22,40 +74,59 @@ const SelectionScopesManager_1 = require("./SelectionScopesManager");
|
|
|
22
74
|
* @public
|
|
23
75
|
*/
|
|
24
76
|
class SelectionManager {
|
|
77
|
+
_imodelKeyFactory;
|
|
78
|
+
_imodelToolSelectionSyncHandlers = new Map();
|
|
79
|
+
_hiliteSetProviders = new Map();
|
|
80
|
+
_ownsStorage;
|
|
81
|
+
_knownIModels = new Set();
|
|
82
|
+
_currentSelection = new CurrentSelectionStorage();
|
|
83
|
+
_selectionChanges = new rxjs_1.Subject();
|
|
84
|
+
_selectionEventsSubscription;
|
|
85
|
+
_listeners = [];
|
|
86
|
+
/**
|
|
87
|
+
* Underlying selection storage used by this selection manager. Ideally, consumers should use
|
|
88
|
+
* the storage directly instead of using this manager to manipulate selection.
|
|
89
|
+
*/
|
|
90
|
+
selectionStorage;
|
|
91
|
+
/** An event which gets broadcasted on selection changes */
|
|
92
|
+
selectionChange;
|
|
93
|
+
/** Manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */
|
|
94
|
+
scopes;
|
|
25
95
|
/**
|
|
26
96
|
* Creates an instance of SelectionManager.
|
|
27
97
|
*/
|
|
28
98
|
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
99
|
this.selectionChange = new SelectionChangeEvent_1.SelectionChangeEvent();
|
|
36
100
|
this.scopes = props.scopes;
|
|
37
|
-
this.
|
|
101
|
+
this.selectionStorage = props.selectionStorage ?? (0, unified_selection_1.createStorage)();
|
|
102
|
+
this._imodelKeyFactory = props.imodelKeyFactory ?? ((imodel) => (imodel.key.length ? imodel.key : imodel.name));
|
|
38
103
|
this._ownsStorage = props.selectionStorage === undefined;
|
|
39
|
-
this.
|
|
104
|
+
this.selectionStorage.selectionChangeEvent.addListener((args) => this._selectionChanges.next(args));
|
|
40
105
|
this._selectionEventsSubscription = this.streamSelectionEvents();
|
|
41
106
|
this._listeners.push(core_frontend_1.IModelConnection.onOpen.addListener((imodel) => {
|
|
42
|
-
this._knownIModels.
|
|
107
|
+
this._knownIModels.add(imodel);
|
|
43
108
|
}));
|
|
44
109
|
this._listeners.push(core_frontend_1.IModelConnection.onClose.addListener((imodel) => {
|
|
45
110
|
this.onConnectionClose(imodel);
|
|
46
111
|
}));
|
|
47
112
|
}
|
|
48
|
-
dispose() {
|
|
113
|
+
[Symbol.dispose]() {
|
|
49
114
|
this._selectionEventsSubscription.unsubscribe();
|
|
50
115
|
this._listeners.forEach((dispose) => dispose());
|
|
51
116
|
}
|
|
117
|
+
/** @deprecated in 5.0. Use [Symbol.dispose] instead. */
|
|
118
|
+
// istanbul ignore next
|
|
119
|
+
dispose() {
|
|
120
|
+
this[Symbol.dispose]();
|
|
121
|
+
}
|
|
52
122
|
onConnectionClose(imodel) {
|
|
123
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
53
124
|
this._hiliteSetProviders.delete(imodel);
|
|
54
|
-
this._knownIModels.delete(imodel
|
|
55
|
-
this._currentSelection.clear(
|
|
125
|
+
this._knownIModels.delete(imodel);
|
|
126
|
+
this._currentSelection.clear(imodelKey);
|
|
56
127
|
if (this._ownsStorage) {
|
|
57
128
|
this.clearSelection("Connection Close Event", imodel);
|
|
58
|
-
this.
|
|
129
|
+
this.selectionStorage.clearStorage({ imodelKey });
|
|
59
130
|
}
|
|
60
131
|
}
|
|
61
132
|
/** @internal */
|
|
@@ -84,27 +155,30 @@ class SelectionManager {
|
|
|
84
155
|
}
|
|
85
156
|
else {
|
|
86
157
|
this._imodelToolSelectionSyncHandlers.delete(imodel);
|
|
87
|
-
registration.handler.dispose();
|
|
158
|
+
registration.handler[Symbol.dispose]();
|
|
88
159
|
}
|
|
89
160
|
}
|
|
90
161
|
}
|
|
91
162
|
}
|
|
92
163
|
/**
|
|
93
|
-
* Temporarily suspends tool selection synchronization until the returned `
|
|
164
|
+
* Temporarily suspends tool selection synchronization until the returned `Disposable`
|
|
94
165
|
* is disposed.
|
|
95
166
|
*/
|
|
96
167
|
suspendIModelToolSelectionSync(imodel) {
|
|
97
168
|
const registration = this._imodelToolSelectionSyncHandlers.get(imodel);
|
|
98
169
|
if (!registration) {
|
|
99
|
-
|
|
170
|
+
const noop = () => { };
|
|
171
|
+
return { [Symbol.dispose]: noop, dispose: noop };
|
|
100
172
|
}
|
|
101
173
|
const wasSuspended = registration.handler.isSuspended;
|
|
102
174
|
registration.handler.isSuspended = true;
|
|
103
|
-
|
|
175
|
+
const doDispose = () => (registration.handler.isSuspended = wasSuspended);
|
|
176
|
+
return { [Symbol.dispose]: doDispose, dispose: doDispose };
|
|
104
177
|
}
|
|
105
178
|
/** Get the selection levels currently stored in this manager for the specified imodel */
|
|
106
179
|
getSelectionLevels(imodel) {
|
|
107
|
-
|
|
180
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
181
|
+
return this.selectionStorage.getSelectionLevels({ imodelKey });
|
|
108
182
|
}
|
|
109
183
|
/**
|
|
110
184
|
* Get the selection currently stored in this manager
|
|
@@ -114,39 +188,39 @@ class SelectionManager {
|
|
|
114
188
|
* latest selection after changes.
|
|
115
189
|
*/
|
|
116
190
|
getSelection(imodel, level = 0) {
|
|
117
|
-
|
|
191
|
+
const imodelKey = this._imodelKeyFactory(imodel);
|
|
192
|
+
return this._currentSelection.getSelection(imodelKey, level);
|
|
118
193
|
}
|
|
119
194
|
handleEvent(evt) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
195
|
+
const imodelKey = this._imodelKeyFactory(evt.imodel);
|
|
196
|
+
this._knownIModels.add(evt.imodel);
|
|
123
197
|
switch (evt.changeType) {
|
|
124
198
|
case SelectionChangeEvent_1.SelectionChangeType.Add:
|
|
125
|
-
this.
|
|
126
|
-
|
|
199
|
+
this.selectionStorage.addToSelection({
|
|
200
|
+
imodelKey,
|
|
127
201
|
source: evt.source,
|
|
128
202
|
level: evt.level,
|
|
129
203
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
130
204
|
});
|
|
131
205
|
break;
|
|
132
206
|
case SelectionChangeEvent_1.SelectionChangeType.Remove:
|
|
133
|
-
this.
|
|
134
|
-
|
|
207
|
+
this.selectionStorage.removeFromSelection({
|
|
208
|
+
imodelKey,
|
|
135
209
|
source: evt.source,
|
|
136
210
|
level: evt.level,
|
|
137
211
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
138
212
|
});
|
|
139
213
|
break;
|
|
140
214
|
case SelectionChangeEvent_1.SelectionChangeType.Replace:
|
|
141
|
-
this.
|
|
142
|
-
|
|
215
|
+
this.selectionStorage.replaceSelection({
|
|
216
|
+
imodelKey,
|
|
143
217
|
source: evt.source,
|
|
144
218
|
level: evt.level,
|
|
145
219
|
selectables: keysToSelectable(evt.imodel, evt.keys),
|
|
146
220
|
});
|
|
147
221
|
break;
|
|
148
222
|
case SelectionChangeEvent_1.SelectionChangeType.Clear:
|
|
149
|
-
this.
|
|
223
|
+
this.selectionStorage.clearSelection({ imodelKey, source: evt.source, level: evt.level });
|
|
150
224
|
break;
|
|
151
225
|
}
|
|
152
226
|
}
|
|
@@ -293,9 +367,9 @@ class SelectionManager {
|
|
|
293
367
|
streamSelectionEvents() {
|
|
294
368
|
return this._selectionChanges
|
|
295
369
|
.pipe((0, rxjs_1.mergeMap)((args) => {
|
|
296
|
-
const currentSelectables = this.
|
|
370
|
+
const currentSelectables = this.selectionStorage.getSelection({ imodelKey: args.imodelKey, level: args.level });
|
|
297
371
|
return this._currentSelection.computeSelection(args.imodelKey, args.level, currentSelectables, args.selectables).pipe((0, rxjs_1.mergeMap)(({ level, changedSelection }) => {
|
|
298
|
-
const imodel = this._knownIModels.
|
|
372
|
+
const imodel = findIModel(this._knownIModels, this._imodelKeyFactory, args.imodelKey);
|
|
299
373
|
// istanbul ignore if
|
|
300
374
|
if (!imodel) {
|
|
301
375
|
return rxjs_1.EMPTY;
|
|
@@ -318,12 +392,37 @@ class SelectionManager {
|
|
|
318
392
|
}
|
|
319
393
|
}
|
|
320
394
|
exports.SelectionManager = SelectionManager;
|
|
395
|
+
function findIModel(set, imodelKeyFactory, key) {
|
|
396
|
+
for (const imodel of set) {
|
|
397
|
+
if (imodelKeyFactory(imodel) === key) {
|
|
398
|
+
return imodel;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return undefined;
|
|
402
|
+
}
|
|
321
403
|
/** @internal */
|
|
322
404
|
class ToolSelectionSyncHandler {
|
|
405
|
+
_selectionSourceName = "Tool";
|
|
406
|
+
_logicalSelection;
|
|
407
|
+
_imodel;
|
|
408
|
+
_imodelToolSelectionListenerDisposeFunc;
|
|
409
|
+
_asyncsTracker = new presentation_common_1.AsyncTasksTracker();
|
|
410
|
+
isSuspended;
|
|
323
411
|
constructor(imodel, logicalSelection) {
|
|
324
|
-
this.
|
|
325
|
-
this.
|
|
326
|
-
this.
|
|
412
|
+
this._imodel = imodel;
|
|
413
|
+
this._logicalSelection = logicalSelection;
|
|
414
|
+
this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);
|
|
415
|
+
}
|
|
416
|
+
[Symbol.dispose]() {
|
|
417
|
+
this._imodelToolSelectionListenerDisposeFunc();
|
|
418
|
+
}
|
|
419
|
+
/** note: used only it tests */
|
|
420
|
+
get pendingAsyncs() {
|
|
421
|
+
return this._asyncsTracker.pendingAsyncs;
|
|
422
|
+
}
|
|
423
|
+
onToolSelectionChanged = async (ev) => {
|
|
424
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
425
|
+
try {
|
|
327
426
|
// ignore selection change event if the handler is suspended
|
|
328
427
|
if (this.isSuspended) {
|
|
329
428
|
return;
|
|
@@ -339,13 +438,13 @@ class ToolSelectionSyncHandler {
|
|
|
339
438
|
let ids;
|
|
340
439
|
switch (ev.type) {
|
|
341
440
|
case core_frontend_1.SelectionSetEventType.Add:
|
|
342
|
-
ids = ev.
|
|
441
|
+
ids = ev.additions;
|
|
343
442
|
break;
|
|
344
443
|
case core_frontend_1.SelectionSetEventType.Replace:
|
|
345
|
-
ids = ev.set.
|
|
444
|
+
ids = ev.set.active;
|
|
346
445
|
break;
|
|
347
446
|
default:
|
|
348
|
-
ids = ev.
|
|
447
|
+
ids = ev.removals;
|
|
349
448
|
break;
|
|
350
449
|
}
|
|
351
450
|
// we're always using scoped selection changer even if the scope is set to "element" - that
|
|
@@ -353,40 +452,33 @@ class ToolSelectionSyncHandler {
|
|
|
353
452
|
// we can't because otherwise our keys compare fails (presentation components load data with
|
|
354
453
|
// concrete classes)
|
|
355
454
|
const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, (0, SelectionScopesManager_1.createSelectionScopeProps)(this._logicalSelection.scopes.activeScope));
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
455
|
+
const _r = __addDisposableResource(env_1, this._asyncsTracker.trackAsyncTask(), false);
|
|
456
|
+
switch (ev.type) {
|
|
457
|
+
case core_frontend_1.SelectionSetEventType.Add:
|
|
458
|
+
await changer.add(ids, selectionLevel);
|
|
459
|
+
break;
|
|
460
|
+
case core_frontend_1.SelectionSetEventType.Replace:
|
|
461
|
+
await changer.replace(ids, selectionLevel);
|
|
462
|
+
break;
|
|
463
|
+
case core_frontend_1.SelectionSetEventType.Remove:
|
|
464
|
+
await changer.remove(ids, selectionLevel);
|
|
465
|
+
break;
|
|
466
|
+
case core_frontend_1.SelectionSetEventType.Clear:
|
|
467
|
+
await changer.clear(selectionLevel);
|
|
468
|
+
break;
|
|
360
469
|
}
|
|
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
|
-
}
|
|
470
|
+
}
|
|
471
|
+
catch (e_1) {
|
|
472
|
+
env_1.error = e_1;
|
|
473
|
+
env_1.hasError = true;
|
|
474
|
+
}
|
|
475
|
+
finally {
|
|
476
|
+
__disposeResources(env_1);
|
|
477
|
+
}
|
|
478
|
+
};
|
|
387
479
|
}
|
|
388
480
|
exports.ToolSelectionSyncHandler = ToolSelectionSyncHandler;
|
|
389
|
-
const
|
|
481
|
+
const parseElementIds = (ids) => {
|
|
390
482
|
let allPersistent = true;
|
|
391
483
|
let allTransient = true;
|
|
392
484
|
for (const id of core_bentley_1.Id64.iterable(ids)) {
|
|
@@ -421,13 +513,16 @@ const parseIds = (ids) => {
|
|
|
421
513
|
}
|
|
422
514
|
return { persistent: persistentElementIds, transient: transientElementIds };
|
|
423
515
|
};
|
|
424
|
-
function
|
|
425
|
-
for (const id of core_bentley_1.Id64.iterable(
|
|
426
|
-
|
|
516
|
+
function addKeys(target, className, ids) {
|
|
517
|
+
for (const id of core_bentley_1.Id64.iterable(ids)) {
|
|
518
|
+
target.add({ className, id });
|
|
427
519
|
}
|
|
428
520
|
}
|
|
429
|
-
/** @internal */
|
|
430
521
|
class ScopedSelectionChanger {
|
|
522
|
+
name;
|
|
523
|
+
imodel;
|
|
524
|
+
manager;
|
|
525
|
+
scope;
|
|
431
526
|
constructor(name, imodel, manager, scope) {
|
|
432
527
|
this.name = name;
|
|
433
528
|
this.imodel = imodel;
|
|
@@ -437,27 +532,37 @@ class ScopedSelectionChanger {
|
|
|
437
532
|
async clear(level) {
|
|
438
533
|
this.manager.clearSelection(this.name, this.imodel, level);
|
|
439
534
|
}
|
|
440
|
-
async add(
|
|
441
|
-
const keys = await this
|
|
442
|
-
addTransientKeys(transientIds, keys);
|
|
535
|
+
async add(ids, level) {
|
|
536
|
+
const keys = await this.#computeSelection(ids);
|
|
443
537
|
this.manager.addToSelection(this.name, this.imodel, keys, level);
|
|
444
538
|
}
|
|
445
|
-
async remove(
|
|
446
|
-
const keys = await this
|
|
447
|
-
addTransientKeys(transientIds, keys);
|
|
539
|
+
async remove(ids, level) {
|
|
540
|
+
const keys = await this.#computeSelection(ids);
|
|
448
541
|
this.manager.removeFromSelection(this.name, this.imodel, keys, level);
|
|
449
542
|
}
|
|
450
|
-
async replace(
|
|
451
|
-
const keys = await this
|
|
452
|
-
addTransientKeys(transientIds, keys);
|
|
543
|
+
async replace(ids, level) {
|
|
544
|
+
const keys = await this.#computeSelection(ids);
|
|
453
545
|
this.manager.replaceSelection(this.name, this.imodel, keys, level);
|
|
454
546
|
}
|
|
547
|
+
async #computeSelection(ids) {
|
|
548
|
+
let keys = new presentation_common_1.KeySet();
|
|
549
|
+
if (ids.elements) {
|
|
550
|
+
const { persistent, transient } = parseElementIds(ids.elements);
|
|
551
|
+
keys = await this.manager.scopes.computeSelection(this.imodel, persistent, this.scope);
|
|
552
|
+
addKeys(keys, unified_selection_1.TRANSIENT_ELEMENT_CLASSNAME, transient);
|
|
553
|
+
}
|
|
554
|
+
if (ids.models) {
|
|
555
|
+
addKeys(keys, "BisCore.Model", ids.models);
|
|
556
|
+
}
|
|
557
|
+
if (ids.subcategories) {
|
|
558
|
+
addKeys(keys, "BisCore.SubCategory", ids.subcategories);
|
|
559
|
+
}
|
|
560
|
+
return keys;
|
|
561
|
+
}
|
|
455
562
|
}
|
|
456
563
|
/** Stores current selection in `KeySet` format per iModel. */
|
|
457
564
|
class CurrentSelectionStorage {
|
|
458
|
-
|
|
459
|
-
this._currentSelection = new Map();
|
|
460
|
-
}
|
|
565
|
+
_currentSelection = new Map();
|
|
461
566
|
getCurrentSelectionStorage(imodelKey) {
|
|
462
567
|
let storage = this._currentSelection.get(imodelKey);
|
|
463
568
|
if (!storage) {
|
|
@@ -481,9 +586,7 @@ class CurrentSelectionStorage {
|
|
|
481
586
|
* It always stores result of latest resolved call to `computeSelection`.
|
|
482
587
|
*/
|
|
483
588
|
class IModelSelectionStorage {
|
|
484
|
-
|
|
485
|
-
this._currentSelection = new Map();
|
|
486
|
-
}
|
|
589
|
+
_currentSelection = new Map();
|
|
487
590
|
getSelection(level) {
|
|
488
591
|
let entry = this._currentSelection.get(level);
|
|
489
592
|
if (!entry) {
|