Skip to content

Commit

Permalink
Add java based checks and different webviews to VSCode extension (#107)
Browse files Browse the repository at this point in the history
* Introduce java cli to reduce jar sizes and to combine the servers

* Use CLI in the vscode extension and introduce uml-integration package

* Use server launcher manager to start and stop servers

* Listen to state changes of server manager and clean up di

* Allow editor provider to handle multiple webviews

* Add error webview to editor provider

* Handle loading animation in uml-glsp

* Fix crash caused by checking java version

* Ping servers after start

* Make client loading absolute positioned
  • Loading branch information
haydar-metin authored May 5, 2023
1 parent 6f2566b commit 3efcbc4
Show file tree
Hide file tree
Showing 69 changed files with 2,338 additions and 606 deletions.
2 changes: 2 additions & 0 deletions client/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
"outFiles": ["${workspaceFolder}/packages/uml-vscode-integration/extension/lib/*.js"],
"sourceMaps": true,
"env": {
"UML_GLSP_SERVER_DEBUG": "false",
"UML_GLSP_SERVER_LOGGING": "false",
"UML_MODEL_SERVER_DEBUG": "false",
"UML_MODEL_SERVER_LOGGING": "false"
}
}
Expand Down
64 changes: 57 additions & 7 deletions client/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,27 @@
"problemMatcher": []
},
{
"label": "Start Browser Backend and Server Jars",
"label": "Build theia",
"type": "shell",
"command": "yarn start",
"group": {
"kind": "build",
"isDefault": true
},
"command": "yarn prepare:theia",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Start Browser Backend in Debug Mode (expects running Server instances)",
"label": "Build vscode",
"type": "shell",
"command": "yarn start:debug",
"group": {
"kind": "build",
"isDefault": true
},
"command": "yarn prepare:vscode",
"presentation": {
"reveal": "always",
"panel": "new"
Expand All @@ -49,10 +57,52 @@
"problemMatcher": []
},
{
"label": "Open Example in Browser",
"label": "Watch theia",
"type": "shell",
"group": "build",
"command": "yarn watch:theia",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Watch vscode",
"type": "shell",
"group": "build",
"command": "yarn watch:vscode",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Build server",
"type": "shell",
"group": "build",
"command": "yarn build:server",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Copy server",
"type": "shell",
"command": "yarn copy:server",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Start theia instance",
"type": "shell",
"group": "test",
"command": "google-chrome 127.0.0.1:3000",
"command": "yarn start:theia:debug",
"presentation": {
"reveal": "always",
"panel": "new"
Expand Down
2 changes: 1 addition & 1 deletion client/environments/theia-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "biguml-theia",
"version": "0.1.0",
"version": "0.2.0",
"private": true,
"scripts": {
"build": "theia build --mode development",
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"build:server": "cd ../server && mvn clean install && cd ../client && yarn copy:server",
"copy:server": "tsx ./scripts/copy-server.ts",
"depcheck": "npx depcheck --config .depcheck.yml",
"package": "cd packages/uml-vscode-integration/extension && yarn package && mv ./*.vsix ${INIT_CWD}/release",
"package": "cd packages/uml-vscode-integration/extension && yarn vscode:package && mv ./*.vsix ${INIT_CWD}/release",
"package:zip": "yarn package && cd ${INIT_CWD} && zip -r ./release-$(date +%Y%m%d-%H%M).zip ./release",
"prepare": "lerna run prepare",
"prepare:theia": "yarn prepare --include-dependencies=true --scope=biguml-theia",
Expand Down
3 changes: 1 addition & 2 deletions client/packages/uml-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@borkdominik-biguml/uml-common",
"version": "0.1.0",
"version": "0.2.0",
"description": "UML-Common",
"homepage": "https://github.com/borkdominik/bigUML",
"bugs": "https://github.com/borkdominik/bigUML/issues",
Expand All @@ -17,7 +17,6 @@
"scripts": {
"build": "tsc -b && yarn run lint",
"clean": "rimraf lib tsconfig.tsbuildinfo",
"icons": "tsx ./scripts/icons.ts",
"lint": "eslint -c ./.eslintrc.js --ext .ts,.tsx ./src",
"lint:fix": "eslint --fix -c ./.eslintrc.js --ext .ts,.tsx ./src",
"prepare": "yarn run clean && yarn run build",
Expand Down
1 change: 1 addition & 0 deletions client/packages/uml-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@

export * from './environment/configuration';
export * from './language/language';
export * from './typescript.utils';
19 changes: 19 additions & 0 deletions client/packages/uml-common/src/typescript.utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/********************************************************************************
* Copyright (c) 2023 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 assertUnreachable(value: never, message?: string): never {
throw new Error(message ?? `Didn't expect to get here. Passed value: ${value}`);
}
14 changes: 14 additions & 0 deletions client/packages/uml-glsp/css/base/animations.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.client-loading {
width: 100%;
height: 100%;
position: absolute;
top: 0;
z-index: 100;
}

.loading-animation {
width: 100%;
height: 100%;
background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' version='1.1' width='575' height='6px'%3E %3Cstyle%3E circle { animation: ball 2.5s cubic-bezier(0.000, 1.000, 1.000, 0.000) infinite; fill: %23bbb; } %23balls { animation: balls 2.5s linear infinite; } %23circle2 { animation-delay: 0.1s; } %23circle3 { animation-delay: 0.2s; } %23circle4 { animation-delay: 0.3s; } %23circle5 { animation-delay: 0.4s; } @keyframes ball { from { transform: none; } 20% { transform: none; } 80% { transform: translateX(864px); } to { transform: translateX(864px); } } @keyframes balls { from { transform: translateX(-40px); } to { transform: translateX(30px); } } %3C/style%3E %3Cg id='balls'%3E %3Ccircle class='circle' id='circle1' cx='-115' cy='3' r='3'/%3E %3Ccircle class='circle' id='circle2' cx='-130' cy='3' r='3' /%3E %3Ccircle class='circle' id='circle3' cx='-145' cy='3' r='3' /%3E %3Ccircle class='circle' id='circle4' cx='-160' cy='3' r='3' /%3E %3Ccircle class='circle' id='circle5' cx='-175' cy='3' r='3' /%3E %3C/g%3E %3C/svg%3E")
50% no-repeat;
}
1 change: 1 addition & 0 deletions client/packages/uml-glsp/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@import 'common.css';
@import 'uml-sprotty.css';

@import 'base/animations.css';
@import 'base/edge.css';
@import 'base/node.css';
@import 'base/text.css';
Expand Down
2 changes: 1 addition & 1 deletion client/packages/uml-glsp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@borkdominik-biguml/uml-glsp",
"version": "0.1.0",
"version": "0.2.0",
"description": "UML-GLSP",
"homepage": "https://github.com/borkdominik/bigUML",
"bugs": "https://github.com/borkdominik/bigUML/issues",
Expand Down
51 changes: 51 additions & 0 deletions client/packages/uml-glsp/src/base/action-dispatcher.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/********************************************************************************
* Copyright (c) 2023 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 { GLSPActionDispatcher, RequestAction, ResponseAction } from '@eclipse-glsp/client';

export class UMLActionDispatcher extends GLSPActionDispatcher {
override requestUntil<Res extends ResponseAction>(
action: RequestAction<Res>,
timeoutMs = 10000,
rejectOnTimeout = false
): Promise<Res> {
if (!action.requestId && action.requestId === '') {
// No request id has been specified. So we use a generated one.
action.requestId = RequestAction.generateRequestId();
}

const requestId = action.requestId;
const timeout = setTimeout(() => {
const deferred = this.requests.get(requestId);
if (deferred !== undefined) {
// cleanup
clearTimeout(timeout);
this.requests.delete(requestId);

const notification = 'Request ' + requestId + ' (' + action.kind + ') time out after ' + timeoutMs + 'ms.';
if (rejectOnTimeout) {
deferred.reject(notification);
} else {
this.logger.info(this, notification, action);
deferred.resolve();
}
}
}, timeoutMs);
this.timeouts.set(requestId, timeout);

return super.request(action);
}
}
29 changes: 25 additions & 4 deletions client/packages/uml-glsp/src/di.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
configureViewerOptions,
createDiagramContainer,
EditLabelUI,
GLSPActionDispatcher,
GLSPGraph,
GridSnapper,
LogLevel,
Expand All @@ -34,10 +35,13 @@ import {
import toolPaletteModule from '@eclipse-glsp/client/lib/features/tool-palette/di.config';
import { DefaultTypes } from '@eclipse-glsp/protocol';
import { Container, ContainerModule } from 'inversify';
import { UMLActionDispatcher } from './base/action-dispatcher';
import { FixedLogger } from './common/fixed-logger';
import { UML_TYPES } from './di.types';
import { CustomCopyPasteHandler, LastContainableElementTracker } from './features/copy-paste/copy-paste';
import { EditLabelUIAutocomplete } from './features/edit-label';
import editorPanelModule from './features/editor-panel/di.config';
import { initializationModule, IOnceModelInitialized } from './features/initialization/di.config';
import outlineModule from './features/outline/di.config';
import propertyPaletteModule from './features/property-palette/di.config';
import { themeModule } from './features/theme/di.config';
Expand All @@ -55,6 +59,7 @@ export default function createContainer(widgetId: string): Container {

rebind(TYPES.ILogger).to(FixedLogger).inSingletonScope();
rebind(TYPES.LogLevel).toConstantValue(LogLevel.info);
rebind(GLSPActionDispatcher).to(UMLActionDispatcher).inSingletonScope();

bind(TYPES.ISnapper).to(GridSnapper);
rebind(TYPES.ICopyPasteHandler).to(CustomCopyPasteHandler);
Expand All @@ -79,15 +84,31 @@ export default function createContainer(widgetId: string): Container {
});
});

const container = createDiagramContainer(coreDiagramModule);
const container = createDiagramContainer(coreDiagramModule, { exclude: toolPaletteModule });

container.unload(toolPaletteModule);

container.load(themeModule, editorPanelModule, umlToolPaletteModule, outlineModule, propertyPaletteModule, ...umlDiagramModules);
container.load(
initializationModule,
themeModule,
editorPanelModule,
umlToolPaletteModule,
outlineModule,
propertyPaletteModule,
...umlDiagramModules
);

overrideViewerOptions(container, {
baseDiv: widgetId,
hiddenDiv: widgetId + '_hidden'
});
onceModelInitialized(container);

return container;
}

function onceModelInitialized(container: Container): void {
const actionDispatcher = container.get<GLSPActionDispatcher>(TYPES.IActionDispatcher);

actionDispatcher.onceModelInitialized().then(() => {
container.getAll<IOnceModelInitialized>(UML_TYPES.IOnceModelInitialized).forEach(t => t.onceModelInitialized());
});
}
22 changes: 22 additions & 0 deletions client/packages/uml-glsp/src/di.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/********************************************************************************
* Copyright (c) 2023 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 { TYPES } from '@eclipse-glsp/client';

export const UML_TYPES = {
...TYPES,
IOnceModelInitialized: Symbol('IOnceModelInitialized')
};
37 changes: 37 additions & 0 deletions client/packages/uml-glsp/src/features/initialization/di.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/********************************************************************************
* Copyright (c) 2023 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 { TYPES, ViewerOptions } from '@eclipse-glsp/client';
import { ContainerModule, inject, injectable } from 'inversify';
import { UML_TYPES } from '../../di.types';

export const initializationModule = new ContainerModule(bind => {
bind(LoadingHandler).toSelf().inSingletonScope();
bind(UML_TYPES.IOnceModelInitialized).toService(LoadingHandler);
});

export interface IOnceModelInitialized {
onceModelInitialized(): void;
}

@injectable()
export class LoadingHandler implements IOnceModelInitialized {
constructor(@inject(TYPES.ViewerOptions) protected readonly viewerOptions: ViewerOptions) {}

onceModelInitialized(): void {
document.getElementById(this.viewerOptions.baseDiv + '_loading')?.remove();
}
}
17 changes: 17 additions & 0 deletions client/packages/uml-glsp/src/features/initialization/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/********************************************************************************
* Copyright (c) 2023 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 * from './di.config';
5 changes: 5 additions & 0 deletions client/packages/uml-integration/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: '../../.eslintrc.js',
rules: {}
};
Loading

0 comments on commit 3efcbc4

Please sign in to comment.