'use strict' ; import * as vscode from "vscode" ; import { dispose as disposeTelemetryWrapper , initializeFromJsonFile , instrumentOperation } from "vscode-extension-telemetry-wrapper" ; import { TomcatController } from "./Tomcat/TomcatController" ; import { TomcatModel } from "./Tomcat/TomcatModel" ; import { TomcatServer } from "./Tomcat/TomcatServer" ; import { WarPackage } from "./Tomcat/WarPackage" ; import { TomcatSeverTreeProvider } from "./TomcatSeverTreeProvider" ; import { Utility } from "./Utility" ; export async function activate ( context ) { await initializeFromJsonFile ( context . asAbsolutePath ( './package.json' ) , { firstParty : true } ) ; await instrumentOperation ( 'activation' , initializeExtension ) ( context ) ; } async function initializeExtension ( _opId , context ) { let storagePath = context . storagePath ; if ( ! storagePath ) { storagePath = Utility . getTempStoragePath ( ) ; } const tomcatModel = new TomcatModel ( storagePath ) ; const tomcatServerTree = new TomcatSeverTreeProvider ( context , tomcatModel ) ; const tomcatController = new TomcatController ( tomcatModel , context . extensionPath ) ; context . subscriptions . push ( tomcatController ) ; context . subscriptions . push ( tomcatServerTree ) ; context . subscriptions . push ( vscode . window . registerTreeDataProvider ( 'tomcatServerExplorer' , tomcatServerTree ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.tree.refresh' , ( _operationId , server ) => tomcatServerTree . refresh ( server ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.war.browse' , ( operationId , war ) => tomcatController . browseWarPackage ( operationId , war ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.server.rename' , ( operationId , server ) => tomcatController . renameServer ( operationId , server ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.server.add' , ( operationId ) => tomcatController . addServer ( operationId ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.server.start' , ( operationId , server ) => tomcatController . startServer ( operationId , server ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.server.restart' , ( operationId , server ) => tomcatController . stopOrRestartServer ( operationId , server , true ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.server.stop' , ( operationId , server ) => tomcatController . stopOrRestartServer ( operationId , server ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.server.delete' , ( operationId , server ) => tomcatController . deleteServer ( operationId , server ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.server.browse' , ( operationId , server ) => tomcatController . browseServer ( operationId , server ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.server.debug' , ( operationId , server ) => tomcatController . runOrDebugOnServer ( operationId , undefined , true , server ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.war.run' , ( operationId , uri ) => tomcatController . runOrDebugOnServer ( operationId , uri ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.war.debug' , ( operationId , uri ) => tomcatController . runOrDebugOnServer ( operationId , uri , true ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.webapp.run' , ( operationId , uri ) => tomcatController . runOrDebugOnServer ( operationId , uri ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.webapp.debug' , ( operationId , uri ) => tomcatController . runOrDebugOnServer ( operationId , uri , true ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.config.open' , ( operationId , server ) => tomcatController . openServerConfig ( operationId , server ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.war.delete' , ( operationId , warPackage ) => tomcatController . deleteWarPackage ( operationId , warPackage ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.war.reveal' , ( _operationId , warPackage ) => tomcatController . revealWarPackage ( warPackage ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.server.customizejvmoptions' , ( _operationId , server ) => tomcatController . customizeJVMOptions ( server ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.package' , ( ) => tomcatController . generateWarPackage ( ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.server.rename.context' , ( operationId , server ) => tomcatController . renameServer ( operationId , server ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.server.start.context' , ( operationId , server ) => tomcatController . startServer ( operationId , server ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.server.restart.context' , ( operationId , server ) => tomcatController . stopOrRestartServer ( operationId , server , true ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.server.stop.context' , ( operationId , server ) => tomcatController . stopOrRestartServer ( operationId , server ) ) ) ; context . subscriptions . push ( registerCommandWrapper ( 'tomcat.server.delete.context' , ( operationId , server ) => tomcatController . deleteServer ( operationId , server ) ) ) ; } function registerCommandWrapper ( command , callback ) { const instrumented = instrumentOperation ( command , async ( operationId , ... args ) => { await callback ( operationId , ... args ) ; } ) ; return vscode . commands . registerCommand ( command , instrumented ) ; } export async function deactivate ( ) { await disposeTelemetryWrapper ( ) ; }