Cleanup sprotty live beans view

This commit is contained in:
Kris De Volder
2019-08-27 13:05:44 -07:00
parent c49a9f0c83
commit 9708319ea7
18 changed files with 4807 additions and 33830 deletions

View File

@@ -0,0 +1,4 @@
node_modules
bundle.js
bundle.js.map
/lib

View File

@@ -1,5 +1,14 @@
set -ev
# For vscode webview
rm -rf ../../vscode-extensions/vscode-spring-boot/media/*
mkdir -p ../../vscode-extensions/vscode-spring-boot/media
cp bundle.js* ../../vscode-extensions/vscode-spring-boot/media
cp -R css ../../vscode-extensions/vscode-spring-boot/media
cp -R lib ../../vscode-extensions/vscode-spring-boot/media
# For webserver embedded in language server
rm -fr ../../headless-services/spring-boot-language-server/src/main/resources/static/bundle*
rm -fr ../../headless-services/spring-boot-language-server/src/main/resources/static/css
cp bundle.js* ../../headless-services/spring-boot-language-server/src/main/resources/static
cp -R css ../../headless-services/spring-boot-language-server/src/main/resources/static
cp -R lib ../../headless-services/spring-boot-language-server/src/main/resources/static

File diff suppressed because it is too large Load Diff

View File

@@ -19,9 +19,4 @@ console.log("Loaded reflect-metadata");
import runStandalone from "./standalone";
const appDiv = document.getElementById('sprotty-app')
if(appDiv) {
const clientId = appDiv.getAttribute('client-id');
console.log('app.ts : ' + clientId);
runStandalone(clientId || 'spring-boot');
}
runStandalone();

View File

@@ -18,87 +18,26 @@
declare const acquireVsCodeApi: any;
import {
TYPES, IActionDispatcher, SModelElementSchema, SEdgeSchema, SNodeSchema, SGraphSchema,
ModelSource, LocalModelSource, WebSocketDiagramServer, RequestModelAction
TYPES, IActionDispatcher,
ModelSource, WebSocketDiagramServer, RequestModelAction
} from "sprotty";
import createContainer, {TransportMedium} from "./di.config";
import * as SockJS from "sockjs-client";
import {VSCodeWebViewDiagramServer} from "./model";
export default function runStandalone(clientId: string) {
export default function runStandalone() {
const clientId = getOptionFromDom('client-id') || 'sprotty-client';
const container = createContainer(TransportMedium.LSP, clientId);
const dispatcher = container.get<IActionDispatcher>(TYPES.IActionDispatcher);
// Initialize gmodel
const node0 = {
id: 'node0', type: 'node:bean', position: {x: 100, y: 100}, size: {width: 80, height: 80},
layout: 'vbox',
children: [
{
id: 'node0_header',
type: 'compartment',
layout: 'hbox',
children: [
{
id: 'bean-name',
type: 'node:label',
text: 'SpringBootApplication'
}
]
}
]
};
// const children_for_node = [];
const graph: SGraphSchema = {id: 'graph', type: 'graph', children: [node0]};
let count = 2;
function addNode(): SModelElementSchema[] {
const newNode: SNodeSchema = {
id: 'node' + count,
type: 'node:bean',
position: {
x: Math.random() * 1024,
y: Math.random() * 768
},
size: {
width: 80,
height: 80
}
};
const newEdge: SEdgeSchema = {
id: 'edge' + count,
type: 'edge:straight',
sourceId: 'node0',
targetId: 'node' + count++
};
return [newNode, newEdge];
}
for (let i = 0; i < 10; ++i) {
const newElements = addNode();
for (const e of newElements) {
graph.children.splice(0, 0, e);
}
}
// Run
const modelSource = container.get<ModelSource>(TYPES.ModelSource);
console.log('Model source: ' + modelSource);
if (modelSource instanceof LocalModelSource) {
(<LocalModelSource>modelSource).setModel(graph);
}
if (modelSource instanceof WebSocketDiagramServer) {
const ws = new SockJS('http://localhost:8080/websocket');
modelSource.clientId = 'spring-boot';
modelSource.listen(ws);
ws.addEventListener('open', () => {
dispatcher.dispatch(new RequestModelAction());
dispatcher.dispatch(requestModelAction());
});
ws.addEventListener('error', (event) => {
console.error(`WebSocket Error: ${event}`)
@@ -106,16 +45,29 @@ export default function runStandalone(clientId: string) {
}
if (modelSource instanceof VSCodeWebViewDiagramServer) {
console.log('Listen and acquire VSCode API with client-id = ' + clientId);
modelSource.listen(acquireVsCodeApi());
dispatcher.dispatch(new RequestModelAction());
dispatcher.dispatch(requestModelAction());
}
console.log('Before requesting model');
// Button features
document.getElementById('refresh')!.addEventListener('click', () => {
dispatcher.dispatch(new RequestModelAction());
dispatcher.dispatch(requestModelAction());
});
function getOptionFromDom(att: string) : string | null {
const appDiv = document.getElementById('sprotty-app');
if (appDiv) {
return appDiv.getAttribute(att);
}
return null;
}
function getTarget() : string {
return getOptionFromDom('target') || 'target-missing';
}
function requestModelAction() : RequestModelAction {
return new RequestModelAction({ 'target' : getTarget()});
}
}