Remaining client changes
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="row" id="sprotty-app" data-app="circlegraph">
|
||||
<div class="row" id="sprotty-app" client-id="spring-boot">
|
||||
<div class="col-md-10">
|
||||
<h1>sprotty Circles Example</h1>
|
||||
<p>
|
||||
|
||||
@@ -21,9 +21,7 @@ import runStandalone from "./standalone";
|
||||
|
||||
const appDiv = document.getElementById('sprotty-app')
|
||||
if(appDiv) {
|
||||
const appMode = appDiv.getAttribute('data-app');
|
||||
if (appMode === 'circlegraph')
|
||||
runStandalone();
|
||||
else
|
||||
throw new Error('Dunno what to do :-(');
|
||||
const clientId = appDiv.getAttribute('client-id');
|
||||
console.log('app.ts : ' + clientId);
|
||||
runStandalone(clientId || 'spring-boot');
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export class VSCodeWebViewDiagramServer extends DiagramServer {
|
||||
|
||||
listen(vscode: any): void {
|
||||
|
||||
window.addEventListener('message', event => {
|
||||
window.addEventListener('message', (event: any) => {
|
||||
const message = event.data; // The json data that the extension sent
|
||||
console.log('Message Received');
|
||||
this.messageReceived(message);
|
||||
|
||||
@@ -14,18 +14,19 @@
|
||||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
declare const acquireVsCodeApi: any;
|
||||
|
||||
import {
|
||||
TYPES, IActionDispatcher, SModelElementSchema, SEdgeSchema, SNodeSchema, SGraphSchema,
|
||||
ModelSource, LocalModelSource, WebSocketDiagramServer, RequestModelAction
|
||||
} from "sprotty";
|
||||
import createContainer from "./di.config";
|
||||
import createContainer, {TransportMedium} from "./di.config";
|
||||
import * as SockJS from "sockjs-client";
|
||||
import {VSCodeWebViewDiagramServer} from "./model";
|
||||
|
||||
export default function runStandalone() {
|
||||
const container = createContainer(true);
|
||||
export default function runStandalone(clientId: string) {
|
||||
const container = createContainer(TransportMedium.LSP, clientId);
|
||||
const dispatcher = container.get<IActionDispatcher>(TYPES.IActionDispatcher);
|
||||
|
||||
// Initialize gmodel
|
||||
@@ -105,6 +106,7 @@ export default function runStandalone() {
|
||||
}
|
||||
|
||||
if (modelSource instanceof VSCodeWebViewDiagramServer) {
|
||||
console.log('Listen and acquire VSCode API with client-id = ' + clientId);
|
||||
modelSource.listen(acquireVsCodeApi());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user