This repository has been archived by the owner on May 3, 2018. It is now read-only.
/
di.config.ts
56 lines (48 loc) · 2.22 KB
/
di.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* Copyright (C) 2017 TypeFox and others.
*
* Licensed under the Apache License, Version 2.0 (the "License") you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
import { Container, ContainerModule, injectable } from "inversify"
import {
defaultModule, TYPES, ViewRegistry, overrideViewerOptions, ConsoleLogger, LogLevel, boundsModule,
moveModule, fadeModule, hoverModule, SGraphView, HtmlRootView, PreRenderedView, viewportModule,
selectModule
} from "sprotty/lib"
import { FlowModelFactory } from "./flowmodel-factory"
import { TaskNodeView, BarrierNodeView, FlowEdgeView } from "./views"
import { TheiaDiagramServer } from '../diagram/theia-diagram-server'
import { DiagramConfiguration } from '../diagram/diagram-configuration'
const flowModule = new ContainerModule((bind, unbind, isBound, rebind) => {
rebind(TYPES.ILogger).to(ConsoleLogger).inSingletonScope()
rebind(TYPES.LogLevel).toConstantValue(LogLevel.log)
rebind(TYPES.IModelFactory).to(FlowModelFactory).inSingletonScope()
})
@injectable()
export class FlowDiagramConfiguration implements DiagramConfiguration {
get diagramType() {
return 'flow'
}
createContainer(widgetId: string) {
const container = new Container()
container.load(defaultModule, selectModule, moveModule, boundsModule, fadeModule, viewportModule, flowModule, hoverModule)
container.bind(TYPES.ModelSource).to(TheiaDiagramServer).inSingletonScope()
overrideViewerOptions(container, {
baseDiv: widgetId,
hiddenDiv: 'sprotty-hidden-flow',
popupDiv: 'sprotty-popup-flow',
needsClientLayout: false,
needsServerLayout: true
})
// Register views
const viewRegistry = container.get<ViewRegistry>(TYPES.ViewRegistry)
viewRegistry.register('flow', SGraphView)
viewRegistry.register('task', TaskNodeView)
viewRegistry.register('barrier', BarrierNodeView)
viewRegistry.register('edge', FlowEdgeView)
viewRegistry.register('html', HtmlRootView)
viewRegistry.register('pre-rendered', PreRenderedView)
return container
}
}