import { injectable , Bootstrap } from '@cloudbeaver/core-di' ; import { NotificationService } from '@cloudbeaver/core-events' ; import { ActionService , ACTION_OPEN_IN_TAB , KeyBindingService , KEY_BINDING_OPEN_IN_TAB } from '@cloudbeaver/core-view' ; import { DATA_CONTEXT_SQL_EDITOR_STATE } from '@cloudbeaver/plugin-sql-editor' ; import { SqlEditorScreenService } from './Screen/SqlEditorScreenService' ; @ injectable ( ) export class PluginBootstrap extends Bootstrap { constructor ( private readonly actionService , private readonly keyBindingService , private readonly sqlEditorScreenService , private readonly notificationService ) { super ( ) ; } register ( ) { this . actionService . addHandler ( { id : 'sql-editor-screen' , isActionApplicable : ( contexts , action ) => ( action === ACTION_OPEN_IN_TAB && contexts . has ( DATA_CONTEXT_SQL_EDITOR_STATE ) ) , handler : ( context , action ) => { } , } ) ; this . keyBindingService . addKeyBindingHandler ( { id : 'sql-editor' , binding : KEY_BINDING_OPEN_IN_TAB , isBindingApplicable : ( contexts , action ) => action === ACTION_OPEN_IN_TAB , handler : ( contexts , action ) => { const context = contexts . get ( DATA_CONTEXT_SQL_EDITOR_STATE ) ; if ( ! context . executionContext ) { this . notificationService . logError ( { title : 'sql_editor_screen_no_context_title' , message : 'sql_editor_screen_no_context_message' , } ) ; return ; } const url = this . sqlEditorScreenService . createURL ( { connectionId : context . executionContext . connectionId , contextId : context . executionContext . id , } ) ; window . open ( url , '_blank' ) ?. focus ( ) ; } , } ) ; } async load ( ) { } }