Skip to content

Commit

Permalink
Add sv inspector launchview
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jun 10, 2022
1 parent 76c7c87 commit 21fdcc7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
41 changes: 41 additions & 0 deletions plugins/sv-inspector/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,54 @@ import {
import TableChartIcon from '@material-ui/icons/TableChart'
import SvInspectorViewTypeFactory from './SvInspectorView/SvInspectorViewType'

type SvInspectorView = ReturnType<typeof SvInspectorViewTypeFactory>

export default class SvInspectorViewPlugin extends Plugin {
name = 'SvInspectorViewPlugin'

install(pluginManager: PluginManager) {
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) {
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 21fdcc7

Please sign in to comment.