Skip to content
This repository has been archived by the owner on Jan 15, 2020. It is now read-only.

#243 Standalone GLSP implementation #249

Merged
merged 5 commits into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@

\.metadata/

client/examples/workflow/workflow-standalone/app/bundle\.js\.map

client/examples/workflow/workflow-standalone/app/bundle\.js
102 changes: 62 additions & 40 deletions client/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,64 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build all packages",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"command": "yarn",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Start Browser Backend for Workflow Example",
"type": "shell",
"command": "cd examples/workflow/browser-app && yarn start:debug",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Watch all packages",
"type": "shell",
"group": "build",
"command": "yarn watch",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
}
]
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build all packages",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"command": "yarn",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Start Browser Backend for Theia Workflow Example",
"type": "shell",
"command": "cd examples/workflow/browser-app && yarn start:debug",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Watch all packages",
"type": "shell",
"group": "build",
"command": "yarn watch",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Open Workflow Theia Example in Browser",
"type": "shell",
"group": "test",
"command": "google-chrome 127.0.0.1:3000",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Open Workflow Standalone Example in Browser",
"type": "shell",
"group": "test",
"command": "google-chrome examples/workflow/workflow-standalone/app/diagram.html",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
}
]
}
38 changes: 38 additions & 0 deletions client/examples/workflow/workflow-standalone/app/diagram.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<link rel="stylesheet" href="css/sprotty.css">
<link rel="stylesheet" href="css/glsp-sprotty.css">
<style>
html,
body {
width: 100%;
height: 100%;
}

#sprotty {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}

svg {
width: 100%;
height: 100%;
overflow: hidden;
}
</style>
<!-- support Microsoft browsers -->
<script src="lib/dom.js">/* DOM4 */</script>
</head>

<body>
<div id="sprotty"></div>
<script src="bundle.js"></script>
</body>

</html>
50 changes: 50 additions & 0 deletions client/examples/workflow/workflow-standalone/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"private": true,
"name": "workflow-standalone",
"version": "0.1.0",
"description": "Standalone browser-app for the Workflow example",
"dependencies": {
"reconnecting-websocket": "^3.0.7",
"@glsp/sprotty-client": "0.1.0",
"@glsp-examples/workflow-sprotty": "0.1.0",
"vscode-ws-jsonrpc": "latest"
},
"devDependencies": {
"@types/chai": "^4.0.1",
"@types/file-saver": "^0.0.1",
"@types/mocha": "^2.2.41",
"@types/node": "^8.0.14",
"chai": "^4.1.0",
"circular-dependency-plugin": "^2.0.0",
"core-js": "^2.5.1",
"css-loader": "^2.1.0",
"http-server": "^0.11.1",
"jenkins-mocha": "^6.0.0",
"jsdom": "9.12.0",
"jsdom-global": "2.1.1",
"mocha": "^3.4.2",
"nyc": "^11.0.3",
"reconnecting-websocket": "^3.0.7",
"reflect-metadata": "^0.1.10",
"rimraf": "^2.6.1",
"semver": "5.6.0",
"snabbdom-to-html": "^3.1.1",
"source-map-loader": "^0.2.3",
"style-loader": "^0.23.1",
"ts-loader": "^4.4.2",
"ts-node": "<7.0.0",
"tslint": "^5.5.0",
"tslint-loader": "^3.4.3",
"typescript": "2.9.1",
"typings": "^2.1.0",
"webpack": "^4.15.1",
"webpack-cli": "^3.0.8"
},
"scripts": {
"prepare": "yarn run clean && yarn build",
"clean": "rimraf lib app/bundle.js app/bundle.js.map app/css",
"lint": "tslint -c ../../../configs/tslint.json --project ./tsconfig.json",
"build": "tsc && yarn lint && webpack",
"watch": "tsc -w -p ./tsconfig.json"
}
}
28 changes: 28 additions & 0 deletions client/examples/workflow/workflow-standalone/src/di.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/********************************************************************************
* Copyright (c) 2019 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { createWorkflowDiagramContainer } from "@glsp-examples/workflow-sprotty/lib";
import { GLSPWebsocketDiagramServer, registerDefaultTools } from "@glsp/sprotty-client/lib";
import { Container } from "inversify";
import { ConsoleLogger, LogLevel, TYPES } from "sprotty/lib";

export default function createContainer(): Container {
const container = createWorkflowDiagramContainer('sprotty');
container.bind(TYPES.ModelSource).to(GLSPWebsocketDiagramServer).inSingletonScope();
container.rebind(TYPES.ILogger).to(ConsoleLogger).inSingletonScope();
container.rebind(TYPES.LogLevel).toConstantValue(LogLevel.warn);
registerDefaultTools(container);
return container;
}
43 changes: 43 additions & 0 deletions client/examples/workflow/workflow-standalone/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/********************************************************************************
* Copyright (c) 2019 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import "reflect-metadata";
import "sprotty-theia/css/theia-sprotty.css";

import { GLSPWebsocketDiagramServer, RequestOperationsAction, RequestTypeHintsAction } from "@glsp/sprotty-client/lib";
import { join, resolve } from "path";
import { IActionDispatcher, RequestModelAction, TYPES } from "sprotty";

import createContainer from "./di.config";

const container = createContainer();

const websocket = new WebSocket("ws://localhost:8081/process");
const loc = window.location.pathname;
const currentDir = loc.substring(0, loc.lastIndexOf('/'));
const examplePath = resolve(join(currentDir, '..', '..', 'workspace', 'example1.wf'));

const diagramServer = container.get<GLSPWebsocketDiagramServer>(TYPES.ModelSource);
diagramServer.listen(websocket);
const actionDispatcher = container.get<IActionDispatcher>(TYPES.IActionDispatcher);
websocket.addEventListener('open', event => {
actionDispatcher.dispatch(new RequestModelAction({
sourceUri: `file://${examplePath}`,
diagramType: "workflow-diagram",
needsClientLayout: "true"
}));
actionDispatcher.dispatch(new RequestOperationsAction());
actionDispatcher.dispatch(new RequestTypeHintsAction("workflow-diagram"));
});
35 changes: 35 additions & 0 deletions client/examples/workflow/workflow-standalone/src/url-parameters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/********************************************************************************
* Copyright (c) 2019 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
export function getParameters(): { [key: string]: string } {
let search = window.location.search.substring(1);
const result = {};
while (search.length > 0) {
const nextParamIndex = search.indexOf('&');
let param: string;
if (nextParamIndex < 0) {
param = search;
search = '';
} else {
param = search.substring(0, nextParamIndex);
search = search.substring(nextParamIndex + 1);
}
const valueIndex = param.indexOf('=');
if (valueIndex > 0 && valueIndex < param.length - 1) {
result[param.substring(0, valueIndex)] = decodeURIComponent(param.substring(valueIndex + 1));
}
}
return result;
}
12 changes: 12 additions & 0 deletions client/examples/workflow/workflow-standalone/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../../configs/base.tsconfig",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib",
"baseUrl": ".",
"noImplicitAny": false
},
"include": [
"src"
]
}
63 changes: 63 additions & 0 deletions client/examples/workflow/workflow-standalone/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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
*/
const webpack = require('webpack');
const path = require('path');

const buildRoot = path.resolve(__dirname, 'lib');
const appRoot = path.resolve(__dirname, 'app');
var CircularDependencyPlugin = require('circular-dependency-plugin');


module.exports = {
entry: [
'core-js/es6/map',
'core-js/es6/promise',
'core-js/es6/string',
'core-js/es6/symbol',
path.resolve(buildRoot, 'main')
],
output: {
filename: 'bundle.js',
path: appRoot
},
mode: 'development',
devtool: 'source-map',
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: ['.webpack.js', '.web.js', '.ts', '.tsx', '.js']
},
module: {
rules: [
// all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
{
test: /\.tsx?$/,
use: [{
loader: 'ts-loader',
options: {
configFile: path.resolve(__dirname, 'examples.tsconfig.json')
}
}]
},
{
test: /\.css$/,
exclude: /\.useable\.css$/,
loader: 'style-loader!css-loader'
}
]
},
node : { fs: 'empty', net: 'empty' },
plugins: [
new CircularDependencyPlugin({
exclude: /(node_modules|examples)\/./,
failOnError: false
}),
new webpack.WatchIgnorePlugin([
/\.js$/,
/\.d\.ts$/
])
]
};
Loading