import { ContainerModule , Container } from 'inversify' ; import { CommandContribution , MenuContribution } from '@theia/core/lib/common' ; import { FrontendApplicationContribution , OpenHandler , KeybindingContribution , KeybindingContext , WidgetFactory } from '@theia/core/lib/browser' ; import { SearchBoxFactory , SearchBox , SearchBoxProps } from '@theia/core/lib/browser/tree/search-box' ; import { SearchBoxDebounce } from '@theia/core/lib/browser/tree/search-box-debounce' ; import { DiagramConfiguration , DiagramManagerProvider , DiagramManager , DiagramWidgetFactory , DiagramWidgetOptions , TheiaSprottyConnector } from 'sprotty-theia' ; import { DepGraphDiagramConfiguration } from './widget/diagram-config' ; import { DepGraphDiagramManager } from './widget/diagram-manager' ; import { DiagramFrontendContribution , DepgraphKeybindingContext } from './widget/diagram-frontend-contribution' ; import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution' ; import { DepGraphWidget } from './widget/diagram-widget' ; import 'sprotty/css/sprotty.css' ; import 'sprotty-theia/css/theia-sprotty.css' ; import '../../src/browser/style/depgraph.css' ; export default new ContainerModule ( bind => { bind ( DiagramConfiguration ) . to ( DepGraphDiagramConfiguration ) . inSingletonScope ( ) ; bind ( DepGraphDiagramManager ) . toDynamicValue ( context => { const childContainer = new Container ( ) ; childContainer . parent = context . container ; childContainer . bind ( DiagramWidgetFactory ) . toFactory ( _ => { return ( options , widgetId , diContainer , connector ? ) => new DepGraphWidget ( options , createSearchBox , widgetId , diContainer , connector ) ; } ) ; return childContainer . resolve ( DepGraphDiagramManager ) ; } ) . inSingletonScope ( ) ; bind ( DiagramManagerProvider ) . toProvider < DiagramManager > ( context => { return ( ) => Promise . resolve ( context . container . get ( DepGraphDiagramManager ) ) ; } ) . whenTargetNamed ( 'dependency-graph' ) ; bind ( FrontendApplicationContribution ) . toService ( DepGraphDiagramManager ) ; bind ( OpenHandler ) . toService ( DepGraphDiagramManager ) ; bind ( WidgetFactory ) . toService ( DepGraphDiagramManager ) ; bind ( DepgraphKeybindingContext ) . toSelf ( ) . inSingletonScope ( ) ; bind ( KeybindingContext ) . toService ( DepgraphKeybindingContext ) ; bind ( DiagramFrontendContribution ) . toSelf ( ) . inSingletonScope ( ) ; bind ( CommandContribution ) . toService ( DiagramFrontendContribution ) ; bind ( KeybindingContribution ) . toService ( DiagramFrontendContribution ) ; bind ( MenuContribution ) . toService ( DiagramFrontendContribution ) ; bind ( ColorContribution ) . toService ( DiagramFrontendContribution ) ; } ) ; export const createSearchBox = ( props ) => { const debounce = new SearchBoxDebounce ( { delay : 300 } ) ; return new SearchBox ( props , debounce ) ; } ;