UNPKG

@itwin/appui-abstract

Version:
222 lines • 13.3 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module UiAdmin */ import { BentleyError, BentleyStatus, BeUiEvent } from "@itwin/core-bentley"; /** The GenericUiEvent is the base event class for UI events that target a specific component, as identified in uiComponentId. * @public */ export class GenericUiEvent extends BeUiEvent { } /** The UiAdmin controls various UI components and is callable from IModelApp.uiAdmin in the core-frontend package. * @public */ export class UiAdmin { _featureFlags = {}; static _messagePresenter; /** The MessagePresenter used to display messages. */ static get messagePresenter() { if (!UiAdmin._messagePresenter) { const error = new BentleyError(BentleyStatus.ERROR, "UiAdmin.messagePresenter not set"); error.category = "messagePresenter"; throw error; } return UiAdmin._messagePresenter; } static set messagePresenter(mp) { UiAdmin._messagePresenter = mp; } get featureFlags() { return { ...this._featureFlags }; // return copy so no direct access to modify value } updateFeatureFlags(uiFlags) { this._featureFlags = { ...this._featureFlags, ...uiFlags }; } /** @internal */ onInitialized() { } /** Get the cursor X and Y position. */ get cursorPosition() { return { x: 0, y: 0 }; } /** Create a PointProps object. * @deprecated in 4.2.x - will not be removed until after 2026-06-13. Please use @core/geometry [[XAndY]] or a custom implementation. */ createXAndY(x, y) { return { x, y }; } /** Determines if focus is set to Home */ get isFocusOnHome() { return false; } /** Sets focus to Home */ setFocusToHome() { } /** Show a context menu at a particular location. * @param _menuItemsProps Properties of the menu items to display. * @param _location Location of the context menu, relative to the origin of htmlElement or the window. * @param _htmlElement The HTMLElement that anchors the context menu. If undefined, the location is relative to the overall window. * @return true if the menu was displayed, false if the menu could not be displayed. */ showContextMenu(_menuItemsProps, _location, _htmlElement) { return false; } /** Show a Toolbar at a particular location. * @param _toolbarProps Properties of the Toolbar to display. * @param _location Location of the Toolbar, relative to the origin of htmlElement or the window. * @param _offset Offset of the Toolbar from the location. * @param _onItemExecuted Function invoked after a Toolbar item is executed * @param _onCancel Function invoked when the Escape key is pressed or a click occurs outside the Toolbar * @param _relativePosition Position relative to the given location. Defaults to TopRight. * @param _htmlElement The HTMLElement that anchors the Toolbar. If undefined, the location is relative to the overall window. * @return true if the Toolbar was displayed, false if the Toolbar could not be displayed. */ showToolbar(_toolbarProps, _location, _offset, _onItemExecuted, _onCancel, _relativePosition, _htmlElement) { return false; } /** Hides the toolbar. */ hideToolbar() { return false; } /** Show a menu button at a particular location. A menu button opens a context menu. * @param _id Id of the menu button. Multiple menu buttons may be displayed. * @param _menuItemsProps Properties of the menu items to display. * @param _location Location of the context menu, relative to the origin of htmlElement or the window. * @param _htmlElement The HTMLElement that anchors the context menu. If undefined, the location is relative to the overall window. * @return true if the button was displayed, false if the button could not be displayed. */ showMenuButton(_id, _menuItemsProps, _location, _htmlElement) { return false; } /** Hides a menu button. * @param _id Id of the menu button. Multiple menu buttons may be displayed. * @return true if the menu was hidden, false if the menu could not be hidden. */ hideMenuButton(_id) { return false; } /** Show a calculator at a particular location. * @param _initialValue Value initially displayed in the calculator. * @param _resultIcon Icon displayed to the left of the value. * @param _location Location of the calculator, relative to the origin of htmlElement or the window. * @param _onCommit Function called when the OK button or the Enter key is pressed. * @param _onCancel Function called when the Cancel button or the Escape key is pressed. * @param _htmlElement The HTMLElement that anchors the context menu. If undefined, the location is relative to the overall window. * @return true if the calculator was displayed, false if the calculator could not be displayed. */ showCalculator(_initialValue, _resultIcon, _location, _onCommit, _onCancel, _htmlElement) { return false; } /** Hides the calculator. */ hideCalculator() { return false; } /** Show an input editor for an angle value at a particular location. * @param _initialValue Value initially displayed in the editor. * @param _location Location of the editor, relative to the origin of htmlElement or the window. * @param _onCommit Function called when the OK button or the Enter key is pressed. * @param _onCancel Function called when the Cancel button or the Escape key is pressed. * @param _htmlElement The HTMLElement that anchors the context menu. If undefined, the location is relative to the overall window. * @return true if the editor was displayed, false if the editor could not be displayed. */ showAngleEditor(_initialValue, _location, _onCommit, _onCancel, _htmlElement) { return false; } /** Show an input editor for a length value at a particular location. * @param _initialValue Value initially displayed in the editor. * @param _location Location of the editor, relative to the origin of htmlElement or the window. * @param _onCommit Function called when the OK button or the Enter key is pressed. * @param _onCancel Function called when the Cancel button or the Escape key is pressed. * @param _htmlElement The HTMLElement that anchors the context menu. If undefined, the location is relative to the overall window. * @return true if the editor was displayed, false if the editor could not be displayed. */ showLengthEditor(_initialValue, _location, _onCommit, _onCancel, _htmlElement) { return false; } /** Show an input editor for a height value at a particular location. * @param _initialValue Value initially displayed in the editor. * @param _location Location of the editor, relative to the origin of htmlElement or the window. * @param _onCommit Function called when the OK button or the Enter key is pressed. * @param _onCancel Function called when the Cancel button or the Escape key is pressed. * @param _htmlElement The HTMLElement that anchors the context menu. If undefined, the location is relative to the overall window. * @return true if the editor was displayed, false if the editor could not be displayed. */ showHeightEditor(_initialValue, _location, _onCommit, _onCancel, _htmlElement) { return false; } /** Show an input editor for a primitive value at a particular location. * @param _initialValue Value initially displayed in the editor. * @param _propertyDescription Description of the primitive value property. * @param _location Location of the editor, relative to the origin of htmlElement or the window. * @param _onCommit Function called when the OK button or the Enter key is pressed. * @param _onCancel Function called when the Cancel button or the Escape key is pressed. * @param _htmlElement The HTMLElement that anchors the context menu. If undefined, the location is relative to the overall window. * @return true if the editor was displayed, false if the editor could not be displayed. */ showInputEditor(_initialValue, _propertyDescription, _location, _onCommit, _onCancel, _htmlElement) { return false; } /** Hides the input editor. */ hideInputEditor() { return false; } /** Show an HTML element at a particular location. * @param _displayElement The HTMLElement to display * @param _location Location of the tool settings, relative to the origin of anchorElement or the window * @param _offset Offset of the display element from the location * @param _onCancel Function invoked when the Escape key is pressed or a click occurs outside the display element * @param _relativePosition Position relative to the given location. Defaults to TopRight. * @param _anchorElement The HTMLElement that anchors the display element. If undefined, the location is relative to the overall window. * @return true if the display element was displayed, false if the display element could not be displayed. */ showHTMLElement(_displayElement, _location, _offset, _onCancel, _relativePosition, _anchorElement) { return false; } /** Hides the HTML Element. */ hideHTMLElement() { return false; } /** Show a Card containing content, a title and a toolbar at a particular location. * @param _content The HTMLElement of the content to display * @param _title Title to display at the top of the card. * @param _toolbarProps Properties of the Toolbar to display. * @param _location Location of the Card, relative to the origin of anchorElement or the window. * @param _offset Offset of the Card from the location. * @param _onItemExecuted Function invoked after a Toolbar item is executed * @param _onCancel Function invoked when the Escape key is pressed or a click occurs outside the Card * @param _relativePosition Position relative to the given location. Defaults to TopRight. * @param _anchorElement The HTMLElement that anchors the Card. If undefined, the location is relative to the overall window. * @return true if the Card was displayed, false if the Card could not be displayed. */ showCard(_content, _title, _toolbarProps, _location, _offset, _onItemExecuted, _onCancel, _relativePosition, _anchorElement) { return false; } /** Hides the Card. */ hideCard() { return false; } /** Opens a Tool Settings Ui popup at a particular location. * @param _dataProvider The UiDataProvider for the tool settings * @param _location Location of the tool settings, relative to the origin of anchorElement or the window * @param _offset Offset of the tool settings from the location * @param _onCancel Function invoked when the Escape key is pressed or a click occurs outside the tool settings * @param _relativePosition Position relative to the given location. Defaults to TopRight. * @param _anchorElement The HTMLElement that anchors the tool settings. If undefined, the location is relative to the overall window. * @return true if the tool settings were displayed, false if the tool settings could not be displayed. */ openToolSettingsPopup(_dataProvider, _location, _offset, _onCancel, _relativePosition, _anchorElement) { return false; } /** Closes the Tool Settings Ui popup. */ closeToolSettingsPopup() { return false; } /** Show the Keyin Palette to display all support Tool key-ins. * @param _htmlElement The HTMLElement that anchors the Keyin Palette. If undefined, the location is relative to the overall window. * @return true if the Keyin Palette was displayed, false if it could not be displayed. */ showKeyinPalette(_htmlElement) { return false; } /** Hides the Keyin Palette. */ hideKeyinPalette() { return false; } /** Send a UI event */ static sendUiEvent(args) { UiAdmin.onGenericUiEvent.emit(args); } /** GenericUiEvent */ static onGenericUiEvent = new GenericUiEvent(); /** Opens a Dialog and automatically populates it using the properties defined by the UiDataProvider. * @param _uiDataProvider The DialogLayoutDataProvider for the dialog * @param _title Specify title for dialog. * @param _isModal Specify if the dialog is opened as a modal or modeless. * @param _id Id of the dialog that is used to close it. * @param _optionalProps Optional props for Dialog construction. * @return true if the tool settings were displayed, false if the tool settings could not be displayed. */ openDialog(_uiDataProvider, _title, _isModal, _id, _optionalProps) { return false; } /** Closes the Dialog with a given Id. */ closeDialog(_dialogId) { return false; } } //# sourceMappingURL=UiAdmin.js.map