diff --git a/plugins/sv-inspector/src/index.ts b/plugins/sv-inspector/src/index.ts index 0573d9f849..0fc318f3d1 100644 --- a/plugins/sv-inspector/src/index.ts +++ b/plugins/sv-inspector/src/index.ts @@ -7,6 +7,8 @@ import { import TableChartIcon from '@material-ui/icons/TableChart' import SvInspectorViewTypeFactory from './SvInspectorView/SvInspectorViewType' +type SvInspectorView = ReturnType + export default class SvInspectorViewPlugin extends Plugin { name = 'SvInspectorViewPlugin' @@ -14,6 +16,45 @@ export default class SvInspectorViewPlugin extends Plugin { pluginManager.addViewType(() => pluginManager.jbrequire(SvInspectorViewTypeFactory), ) + + pluginManager.addToExtensionPoint( + 'LaunchView-SvInspectorView', + // @ts-ignore + async ({ + session, + assembly, + uri, + fileType, + }: { + session: AbstractSessionModel + assembly: string + uri: string + fileType?: string + }) => { + // add view, make typescript happy with return type + const { rootModel } = pluginManager + const view = rootModel?.session?.addView( + 'SvInspectorView', + ) as SvInspectorView + + if (!view) { + throw new Error('Failed to initialize view') + } + const exts = uri.split('.') + let ext = exts?.pop()?.toUpperCase() + if (ext === 'GZ') { + ext = exts?.pop()?.toUpperCase() + } + + view.spreadsheetView.importWizard.setFileType(fileType || ext || '') + view.spreadsheetView.importWizard.setSelectedAssemblyName(assembly) + view.spreadsheetView.importWizard.setFileSource({ + uri, + locationType: 'UriLocation', + }) + view.spreadsheetView.importWizard.import(assembly) + }, + ) } configure(pluginManager: PluginManager) { diff --git a/yarn.lock b/yarn.lock index 46f36603f6..5ac64e874e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11213,11 +11213,6 @@ ip@^1.1.5: resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.8.tgz#ae05948f6b075435ed3307acce04629da8cdbf48" integrity sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg== -ip@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ip/-/ip-2.0.0.tgz#4cf4ab182fee2314c75ede1276f8c80b479936da" - integrity sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ== - ipaddr.js@1.9.1: version "1.9.1" resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3"