How to use the sprotty/lib.TYPES.ModelSource function in sprotty

To help you get started, we’ve selected a few sprotty examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github crossminer / scava / crossflow / org.eclipse.scava.crossflow.web / src / elkgraph / editor.ts View on Github external
const urlParameters = getParameters()

let initialContent: string
if (urlParameters.compressedContent !== undefined) {
    initialContent = LZString.decompressFromEncodedURIComponent(urlParameters.compressedContent)
} else if (urlParameters.initialContent !== undefined) {
    initialContent = decodeURIComponent(urlParameters.initialContent)
} else {
    initialContent = ``
}

// Create Sprotty viewer
const sprottyContainer = createContainer()
sprottyContainer.bind(TYPES.ModelSource).to(LanguageDiagramServer).inSingletonScope()
const diagramServer = sprottyContainer.get(TYPES.ModelSource)

// Create Monaco editor
const modelUri = 'inmemory:/model.elkt'
const editor = monaco.editor.create(document.getElementById('monaco-editor')!, {
    model: monaco.editor.createModel(initialContent, 'elkt', monaco.Uri.parse(modelUri))
})
editor.updateOptions({
    minimap: { enabled: false }
})
setupModelLink(editor, (event) => {
    return {
        compressedContent: LZString.compressToEncodedURIComponent(editor.getValue())
    }
})

// Create the web socket
github theia-ide / theia-sprotty-example / theia-dsl-extension / src / browser / processor / di.config.ts View on Github external
createContainer(widgetId: string) {
        const container = new Container()
        container.load(defaultModule, boundsModule, selectModule, moveModule, viewportModule, fadeModule, multicoreModule, hoverModule)
        container.bind(TYPES.ModelSource).to(TheiaDiagramServer).inSingletonScope()

        overrideViewerOptions(container, {
            baseDiv: widgetId,
            hiddenDiv: 'sprotty-hidden-cores',
            popupDiv: 'sprotty-popup-cores',
            needsClientLayout: true,
            needsServerLayout: false
        })

        // Register views
        const viewRegistry = container.get(TYPES.ViewRegistry)
        viewRegistry.register('processor', ProcessorView)
        viewRegistry.register('core', CoreView)
        viewRegistry.register('simplecore', SimpleCoreView)
        viewRegistry.register('crossbar', CrossbarView)
        viewRegistry.register('channel', ChannelView)
github crossminer / scava / crossflow / org.eclipse.scava.crossflow.web / src / elkgraph / editor.ts View on Github external
const WebSocket = require('reconnecting-websocket')

const urlParameters = getParameters()

let initialContent: string
if (urlParameters.compressedContent !== undefined) {
    initialContent = LZString.decompressFromEncodedURIComponent(urlParameters.compressedContent)
} else if (urlParameters.initialContent !== undefined) {
    initialContent = decodeURIComponent(urlParameters.initialContent)
} else {
    initialContent = ``
}

// Create Sprotty viewer
const sprottyContainer = createContainer()
sprottyContainer.bind(TYPES.ModelSource).to(LanguageDiagramServer).inSingletonScope()
const diagramServer = sprottyContainer.get(TYPES.ModelSource)

// Create Monaco editor
const modelUri = 'inmemory:/model.elkt'
const editor = monaco.editor.create(document.getElementById('monaco-editor')!, {
    model: monaco.editor.createModel(initialContent, 'elkt', monaco.Uri.parse(modelUri))
})
editor.updateOptions({
    minimap: { enabled: false }
})
setupModelLink(editor, (event) => {
    return {
        compressedContent: LZString.compressToEncodedURIComponent(editor.getValue())
    }
})
github theia-ide / theia-sprotty-example / theia-dsl-extension / src / browser / flow / di.config.ts View on Github external
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(TYPES.ViewRegistry)
        viewRegistry.register('flow', SGraphView)
        viewRegistry.register('task', TaskNodeView)
        viewRegistry.register('barrier', BarrierNodeView)
        viewRegistry.register('edge', FlowEdgeView)
        viewRegistry.register('html', HtmlRootView)
github eclipsesource / graphical-lsp / client / examples / workflow-glsp-extension / src / browser / workflow-diagram-manager.ts View on Github external
protected createDiagramWidget(uri: URI): DiagramWidget {
        const widgetId = this.widgetRegistry.nextId()
        const svgContainerId = widgetId + '_sprotty'
        const diagramConfiguration = this.diagramConfigurationRegistry.get(this.diagramType)
        const diContainer = diagramConfiguration.createContainer(svgContainerId)
        const modelSource = diContainer.get(TYPES.ModelSource)
        if (modelSource instanceof DiagramServer)
            modelSource.clientId = widgetId
        if (modelSource instanceof TheiaLSPDiagramServer && this.diagramConnector)
            this.diagramConnector.connect(modelSource)
        else if (modelSource instanceof TheiaWebsocketDiagramServer) {
            modelSource.listen(this.glspClient.webSocket)
        }
        const newWidget = this.diagramWidgetFactory({
            id: widgetId, svgContainerId, uri, diagramType: this.diagramType, modelSource,
            actionDispatcher: diContainer.get(TYPES.IActionDispatcher)
        })
        newWidget.title.closable = true
        newWidget.title.label = uri.path.base
        newWidget.title.icon = this.iconClass
        this.widgetRegistry.addWidget(uri, this.diagramType, newWidget)
        newWidget.disposed.connect(() => {
github eclipsesource / graphical-lsp / client / examples / workflow-glsp-extension / src / browser / di.config.ts View on Github external
createContainer(widgetId: string): Container {
        const container = createWorkflowDiagramContainer(widgetId);
        container.bind(TYPES.ModelSource).to(TheiaWebsocketDiagramServer)
        container.rebind(KeyTool).to(TheiaKeyTool).inSingletonScope()
        return container;
    }
github theia-ide / theia-sprotty-example / theia-dsl-extension / src / browser / diagram / theia-diagram-server-connector.ts View on Github external
createDiagramServer(widgetId: string, diagramType: string): TheiaDiagramServer {
        const diagramConfiguration = this.diagramConfigurationRegistry.get(diagramType)
        const newServer = diagramConfiguration.createContainer(widgetId).get(TYPES.ModelSource)
        newServer.connect(this)
        this.servers.push(newServer)
        return newServer
    }
github theia-ide / yangster / theia-yang-extension / src / frontend / yangdiagram / di.config.ts View on Github external
createContainer(widgetId: string): Container {
        const container = createYangDiagramContainer(widgetId)
        container.bind(TYPES.ModelSource).to(TheiaDiagramServer).inSingletonScope()
        container.rebind(KeyTool).to(TheiaKeyTool).inSingletonScope()
        return container
    }
}
github theia-ide / yangster / theia-yang-extension / src / frontend / yangdiagram / di.config.ts View on Github external
createContainer(widgetId: string): Container {
        const container = createYangDiagramContainer(widgetId)
        container.bind(YangDiagramServer).toSelf().inSingletonScope();
        container.bind(TheiaDiagramServer).toService(YangDiagramServer);
        container.bind(LSTheiaDiagramServer).toService(YangDiagramServer);
        container.bind(TYPES.ModelSource).toService(TheiaDiagramServer);
        container.bind(EditDiagramLocker).toSelf().inSingletonScope()
        container.rebind(KeyTool).to(TheiaKeyTool).inSingletonScope();

        container.bind(LSTheiaDiagramServerProvider).toProvider((context) => {
            return () => {
                return new Promise((resolve) => {
                    resolve(context.container.get(LSTheiaDiagramServer));
                });
            };
        });

        return container
    }
}
github TypeFox / npm-dependency-graph / depgraph-navigator / src / browser / graph / resolve-nodes.ts View on Github external
    constructor(@inject(TYPES.ModelSource) protected readonly modelSource: DepGraphModelSource) {}