-
Notifications
You must be signed in to change notification settings - Fork 2
/
StandardStatusbarItemsProvider.tsx
72 lines (68 loc) · 2.63 KB
/
StandardStatusbarItemsProvider.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module StandardUiItemsProvider
*/
import type { DefaultStatusbarItems } from "./StandardStatusbarUiItemsProvider";
import { StandardStatusbarUiItemsProvider } from "./StandardStatusbarUiItemsProvider";
import type { StatusBarItem } from "../statusbar/StatusBarItem";
import { UiItemsManager } from "./UiItemsManager";
import { BaseUiItemsProvider } from "./BaseUiItemsProvider";
/**
* Provide standard statusbar fields for the SimpleStatusbarWidget
* @public
*/
export class StandardStatusbarItemsProvider extends BaseUiItemsProvider {
private uiItemsProvider: StandardStatusbarUiItemsProvider;
constructor(
providerId: string,
_defaultItems?: DefaultStatusbarItems | undefined,
isSupportedStage?: (
stageId: string,
stageUsage: string,
stageAppData?: any
) => boolean
) {
super(providerId, isSupportedStage);
this.uiItemsProvider = new StandardStatusbarUiItemsProvider(_defaultItems);
}
/**
* static function to register the StandardStatusbarItemsProvider
* @param providerId - unique identifier for this instance of the provider. This is required in case separate packages want
* to set up custom stage with their own subset of standard status bar items.
* @param defaultItems - if undefined all available item are provided to stage except for activityCenter. If defined only those
* specific tool buttons are shown.
* @param isSupportedStage - optional function that will be called to determine if tools should be added to current stage. If not set and
* the current stage's `usage` is set to `StageUsage.General` then the provider will add items to frontstage.
*/
public static register(
providerId: string,
defaultItems?: DefaultStatusbarItems,
isSupportedStage?: (
stageId: string,
stageUsage: string,
stageAppData?: any
) => boolean
) {
const provider = new StandardStatusbarItemsProvider(
providerId,
defaultItems,
isSupportedStage
);
UiItemsManager.register(provider);
return provider;
}
public override provideStatusBarItemsInternal(
_stageId: string,
_stageUsage: string,
_stageAppData?: any
): StatusBarItem[] {
return this.uiItemsProvider.provideStatusBarItems(
_stageId,
_stageUsage,
_stageAppData
);
}
}