@eclipse-glsp/vscode-integration-webview 0.9.0-next.11de3de8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +276 -0
- package/README.md +15 -0
- package/css/command-palette.css +100 -0
- package/css/decoration.css +25 -0
- package/css/diagram.css +61 -0
- package/css/glsp-vscode.css +23 -0
- package/css/tool-palette.css +92 -0
- package/lib/extension-action-handler.d.ts +30 -0
- package/lib/extension-action-handler.d.ts.map +1 -0
- package/lib/extension-action-handler.js +30 -0
- package/lib/extension-action-handler.js.map +1 -0
- package/lib/glsp-starter.d.ts +11 -0
- package/lib/glsp-starter.d.ts.map +1 -0
- package/lib/glsp-starter.js +58 -0
- package/lib/glsp-starter.js.map +1 -0
- package/lib/glsp-vscode-diagram-widget.d.ts +6 -0
- package/lib/glsp-vscode-diagram-widget.d.ts.map +1 -0
- package/lib/glsp-vscode-diagram-widget.js +50 -0
- package/lib/glsp-vscode-diagram-widget.js.map +1 -0
- package/lib/glsp-vscode-diagramserver.d.ts +32 -0
- package/lib/glsp-vscode-diagramserver.d.ts.map +1 -0
- package/lib/glsp-vscode-diagramserver.js +105 -0
- package/lib/glsp-vscode-diagramserver.js.map +1 -0
- package/lib/index.d.ts +18 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +30 -0
- package/lib/index.js.map +1 -0
- package/package.json +55 -0
- package/src/extension-action-handler.ts +42 -0
- package/src/glsp-starter.ts +64 -0
- package/src/glsp-vscode-diagram-widget.ts +47 -0
- package/src/glsp-vscode-diagramserver.ts +108 -0
- package/src/index.ts +17 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glsp-starter.d.ts","sourceRoot":"","sources":["../src/glsp-starter.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACH,wBAAwB,EACxB,cAAc,EAIjB,MAAM,wBAAwB,CAAC;AAKhC,8BAAsB,WAAY,SAAQ,cAAc;IACpD,SAAS,CAAC,iBAAiB,CAAC,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,wBAAwB,GAAG,IAAI;IAepG,SAAS,CAAC,+BAA+B,CAAC,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,wBAAwB,GAAG,IAAI;IAMlH;;OAEG;IACH,SAAS,KAAK,oBAAoB,IAAI,MAAM,EAAE,CAQ7C;CACJ"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GLSPStarter = void 0;
|
|
4
|
+
/********************************************************************************
|
|
5
|
+
* Copyright (c) 2020-2021 EclipseSource and others.
|
|
6
|
+
*
|
|
7
|
+
* This program and the accompanying materials are made available under the
|
|
8
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
9
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
10
|
+
*
|
|
11
|
+
* This Source Code may also be made available under the following Secondary
|
|
12
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
13
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
14
|
+
* with the GNU Classpath Exception which is available at
|
|
15
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
16
|
+
*
|
|
17
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
18
|
+
********************************************************************************/
|
|
19
|
+
const client_1 = require("@eclipse-glsp/client");
|
|
20
|
+
const copy_paste_actions_1 = require("@eclipse-glsp/client/lib/features/copy-paste/copy-paste-actions");
|
|
21
|
+
const sprotty_vscode_webview_1 = require("sprotty-vscode-webview");
|
|
22
|
+
const extension_action_handler_1 = require("./extension-action-handler");
|
|
23
|
+
const glsp_vscode_diagram_widget_1 = require("./glsp-vscode-diagram-widget");
|
|
24
|
+
const glsp_vscode_diagramserver_1 = require("./glsp-vscode-diagramserver");
|
|
25
|
+
class GLSPStarter extends sprotty_vscode_webview_1.SprottyStarter {
|
|
26
|
+
addVscodeBindings(container, diagramIdentifier) {
|
|
27
|
+
container.bind(glsp_vscode_diagram_widget_1.GLSPVscodeDiagramWidget).toSelf().inSingletonScope();
|
|
28
|
+
container.bind(sprotty_vscode_webview_1.VscodeDiagramWidget).toService(glsp_vscode_diagram_widget_1.GLSPVscodeDiagramWidget);
|
|
29
|
+
container
|
|
30
|
+
.bind(sprotty_vscode_webview_1.VscodeDiagramWidgetFactory)
|
|
31
|
+
.toFactory(context => () => context.container.get(glsp_vscode_diagram_widget_1.GLSPVscodeDiagramWidget));
|
|
32
|
+
container.bind(sprotty_vscode_webview_1.SprottyDiagramIdentifier).toConstantValue(diagramIdentifier);
|
|
33
|
+
container.bind(glsp_vscode_diagramserver_1.GLSPVscodeDiagramServer).toSelf().inSingletonScope();
|
|
34
|
+
container.bind(sprotty_vscode_webview_1.VscodeDiagramServer).toService(glsp_vscode_diagramserver_1.GLSPVscodeDiagramServer);
|
|
35
|
+
container.bind(client_1.TYPES.ModelSource).toService(glsp_vscode_diagramserver_1.GLSPVscodeDiagramServer);
|
|
36
|
+
container.bind(client_1.DiagramServer).toService(glsp_vscode_diagramserver_1.GLSPVscodeDiagramServer);
|
|
37
|
+
this.configureExtensionActionHandler(container, diagramIdentifier);
|
|
38
|
+
}
|
|
39
|
+
configureExtensionActionHandler(container, diagramIdentifier) {
|
|
40
|
+
const extensionActionHandler = new extension_action_handler_1.GLSPVscodeExtensionActionHandler(this.extensionActionKinds, diagramIdentifier);
|
|
41
|
+
container.bind(extension_action_handler_1.GLSPVscodeExtensionActionHandler).toConstantValue(extensionActionHandler);
|
|
42
|
+
container.bind(client_1.TYPES.IActionHandlerInitializer).toService(extension_action_handler_1.GLSPVscodeExtensionActionHandler);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* All kinds of actions that should (also) be delegated to and handled by the vscode extension
|
|
46
|
+
*/
|
|
47
|
+
get extensionActionKinds() {
|
|
48
|
+
return [
|
|
49
|
+
client_1.NavigateToExternalTargetAction.KIND,
|
|
50
|
+
copy_paste_actions_1.RequestClipboardDataAction.KIND,
|
|
51
|
+
copy_paste_actions_1.SetClipboardDataAction.KIND,
|
|
52
|
+
client_1.SelectAction.KIND,
|
|
53
|
+
client_1.ExportSvgAction.KIND
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.GLSPStarter = GLSPStarter;
|
|
58
|
+
//# sourceMappingURL=glsp-starter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glsp-starter.js","sourceRoot":"","sources":["../src/glsp-starter.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,iDAA2H;AAC3H,wGAAqI;AAErI,mEAMgC;AAChC,yEAA8E;AAC9E,6EAAuE;AACvE,2EAAsE;AAEtE,MAAsB,WAAY,SAAQ,uCAAc;IAC1C,iBAAiB,CAAC,SAAoB,EAAE,iBAA2C;QACzF,SAAS,CAAC,IAAI,CAAC,oDAAuB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;QACpE,SAAS,CAAC,IAAI,CAAC,4CAAmB,CAAC,CAAC,SAAS,CAAC,oDAAuB,CAAC,CAAC;QACvE,SAAS;aACJ,IAAI,CAAC,mDAA0B,CAAC;aAChC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAA0B,oDAAuB,CAAC,CAAC,CAAC;QACzG,SAAS,CAAC,IAAI,CAAC,iDAAwB,CAAC,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;QAC5E,SAAS,CAAC,IAAI,CAAC,mDAAuB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;QACpE,SAAS,CAAC,IAAI,CAAC,4CAAmB,CAAC,CAAC,SAAS,CAAC,mDAAuB,CAAC,CAAC;QACvE,SAAS,CAAC,IAAI,CAAC,cAAK,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,mDAAuB,CAAC,CAAC;QACrE,SAAS,CAAC,IAAI,CAAC,sBAAa,CAAC,CAAC,SAAS,CAAC,mDAAuB,CAAC,CAAC;QAEjE,IAAI,CAAC,+BAA+B,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;IACvE,CAAC;IAES,+BAA+B,CAAC,SAAoB,EAAE,iBAA2C;QACvG,MAAM,sBAAsB,GAAG,IAAI,2DAAgC,CAAC,IAAI,CAAC,oBAAoB,EAAE,iBAAiB,CAAC,CAAC;QAClH,SAAS,CAAC,IAAI,CAAC,2DAAgC,CAAC,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC;QACzF,SAAS,CAAC,IAAI,CAAC,cAAK,CAAC,yBAAyB,CAAC,CAAC,SAAS,CAAC,2DAAgC,CAAC,CAAC;IAChG,CAAC;IAED;;OAEG;IACH,IAAc,oBAAoB;QAC9B,OAAO;YACH,uCAA8B,CAAC,IAAI;YACnC,+CAA0B,CAAC,IAAI;YAC/B,2CAAsB,CAAC,IAAI;YAC3B,qBAAY,CAAC,IAAI;YACjB,wBAAe,CAAC,IAAI;SACvB,CAAC;IACN,CAAC;CACJ;AAlCD,kCAkCC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { VscodeDiagramWidget } from 'sprotty-vscode-webview';
|
|
2
|
+
export declare abstract class GLSPVscodeDiagramWidget extends VscodeDiagramWidget {
|
|
3
|
+
protected initializeSprotty(): void;
|
|
4
|
+
}
|
|
5
|
+
export declare function decodeURI(uri: string): string;
|
|
6
|
+
//# sourceMappingURL=glsp-vscode-diagram-widget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glsp-vscode-diagram-widget.d.ts","sourceRoot":"","sources":["../src/glsp-vscode-diagram-widget.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,8BACsB,uBAAwB,SAAQ,mBAAmB;IACrE,SAAS,CAAC,iBAAiB,IAAI,IAAI;CAetC;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.decodeURI = exports.GLSPVscodeDiagramWidget = void 0;
|
|
10
|
+
/********************************************************************************
|
|
11
|
+
* Copyright (c) 2020-2021 EclipseSource and others.
|
|
12
|
+
*
|
|
13
|
+
* This program and the accompanying materials are made available under the
|
|
14
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
15
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
16
|
+
*
|
|
17
|
+
* This Source Code may also be made available under the following Secondary
|
|
18
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
19
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
20
|
+
* with the GNU Classpath Exception which is available at
|
|
21
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
22
|
+
*
|
|
23
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
24
|
+
********************************************************************************/
|
|
25
|
+
const client_1 = require("@eclipse-glsp/client");
|
|
26
|
+
const inversify_1 = require("inversify");
|
|
27
|
+
const sprotty_vscode_webview_1 = require("sprotty-vscode-webview");
|
|
28
|
+
let GLSPVscodeDiagramWidget = class GLSPVscodeDiagramWidget extends sprotty_vscode_webview_1.VscodeDiagramWidget {
|
|
29
|
+
initializeSprotty() {
|
|
30
|
+
if (this.modelSource instanceof client_1.DiagramServer) {
|
|
31
|
+
this.modelSource.clientId = this.diagramIdentifier.clientId;
|
|
32
|
+
}
|
|
33
|
+
this.actionDispatcher.dispatch(new client_1.InitializeClientSessionAction(this.diagramIdentifier.clientId));
|
|
34
|
+
this.actionDispatcher.dispatch(new client_1.RequestModelAction({
|
|
35
|
+
sourceUri: decodeURI(this.diagramIdentifier.uri),
|
|
36
|
+
diagramType: this.diagramIdentifier.diagramType
|
|
37
|
+
}));
|
|
38
|
+
this.actionDispatcher.dispatch(new client_1.RequestTypeHintsAction(this.diagramIdentifier.diagramType));
|
|
39
|
+
this.actionDispatcher.dispatch(new client_1.EnableToolPaletteAction());
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
GLSPVscodeDiagramWidget = __decorate([
|
|
43
|
+
inversify_1.injectable()
|
|
44
|
+
], GLSPVscodeDiagramWidget);
|
|
45
|
+
exports.GLSPVscodeDiagramWidget = GLSPVscodeDiagramWidget;
|
|
46
|
+
function decodeURI(uri) {
|
|
47
|
+
return decodeURIComponent(uri.replace(/\+/g, ' '));
|
|
48
|
+
}
|
|
49
|
+
exports.decodeURI = decodeURI;
|
|
50
|
+
//# sourceMappingURL=glsp-vscode-diagram-widget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glsp-vscode-diagram-widget.js","sourceRoot":"","sources":["../src/glsp-vscode-diagram-widget.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,iDAM8B;AAC9B,yCAAuC;AACvC,mEAA6D;AAG7D,IAAsB,uBAAuB,GAA7C,MAAsB,uBAAwB,SAAQ,4CAAmB;IAC3D,iBAAiB;QACvB,IAAI,IAAI,CAAC,WAAW,YAAY,sBAAa,EAAE;YAC3C,IAAI,CAAC,WAAW,CAAC,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC;SAC/D;QACD,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,sCAA6B,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC;QACnG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAC1B,IAAI,2BAAkB,CAAC;YACnB,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC;YAChD,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,WAAW;SAClD,CAAC,CACL,CAAC;QAEF,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,+BAAsB,CAAC,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAAC;QAC/F,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,gCAAuB,EAAE,CAAC,CAAC;IAClE,CAAC;CACJ,CAAA;AAhBqB,uBAAuB;IAD5C,sBAAU,EAAE;GACS,uBAAuB,CAgB5C;AAhBqB,0DAAuB;AAkB7C,SAAgB,SAAS,CAAC,GAAW;IACjC,OAAO,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;AACvD,CAAC;AAFD,8BAEC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2020-2021 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import { Action, ActionHandlerRegistry, ActionMessage, ComputedBoundsAction, DeleteElementOperation, ICopyPasteHandler, SetEditModeAction } from '@eclipse-glsp/client';
|
|
17
|
+
import { SelectionService } from '@eclipse-glsp/client/lib/features/select/selection-service';
|
|
18
|
+
import { VscodeDiagramServer } from 'sprotty-vscode-webview';
|
|
19
|
+
export declare const receivedFromServerProperty = "__receivedFromServer";
|
|
20
|
+
export declare const localDispatchProperty = "__localDispatch";
|
|
21
|
+
export declare class GLSPVscodeDiagramServer extends VscodeDiagramServer {
|
|
22
|
+
protected selectionService: SelectionService;
|
|
23
|
+
protected copyPasteHandler: ICopyPasteHandler;
|
|
24
|
+
initialize(registry: ActionHandlerRegistry): void;
|
|
25
|
+
handleLocally(action: Action): boolean;
|
|
26
|
+
protected messageReceived(data: any): void;
|
|
27
|
+
protected checkMessageOrigin(message: ActionMessage): void;
|
|
28
|
+
protected handleComputedBounds(action: ComputedBoundsAction): boolean;
|
|
29
|
+
protected handleDeleteElementOperation(operation: DeleteElementOperation): boolean;
|
|
30
|
+
protected handleSetEditModeAction(action: SetEditModeAction): boolean;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=glsp-vscode-diagramserver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glsp-vscode-diagramserver.d.ts","sourceRoot":"","sources":["../src/glsp-vscode-diagramserver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EACH,MAAM,EACN,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EAEtB,iBAAiB,EAIjB,iBAAiB,EACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,4DAA4D,CAAC;AAE9F,OAAO,EAAmB,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE9E,eAAO,MAAM,0BAA0B,yBAAyB,CAAC;AACjE,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AAEvD,qBAAa,uBAAwB,SAAQ,mBAAmB;IACvB,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,SAAS,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;IAEpF,UAAU,CAAC,QAAQ,EAAE,qBAAqB,GAAG,IAAI;IAsBjD,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAUtC,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAe1C,SAAS,CAAC,kBAAkB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAO1D,SAAS,CAAC,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO;IAIrE,SAAS,CAAC,4BAA4B,CAAC,SAAS,EAAE,sBAAsB,GAAG,OAAO;IAOlF,SAAS,CAAC,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO;CAGxE"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.GLSPVscodeDiagramServer = exports.localDispatchProperty = exports.receivedFromServerProperty = void 0;
|
|
13
|
+
/********************************************************************************
|
|
14
|
+
* Copyright (c) 2020-2021 EclipseSource and others.
|
|
15
|
+
*
|
|
16
|
+
* This program and the accompanying materials are made available under the
|
|
17
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
18
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
19
|
+
*
|
|
20
|
+
* This Source Code may also be made available under the following Secondary
|
|
21
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
22
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
23
|
+
* with the GNU Classpath Exception which is available at
|
|
24
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
25
|
+
*
|
|
26
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
27
|
+
********************************************************************************/
|
|
28
|
+
const client_1 = require("@eclipse-glsp/client");
|
|
29
|
+
const selection_service_1 = require("@eclipse-glsp/client/lib/features/select/selection-service");
|
|
30
|
+
const inversify_1 = require("inversify");
|
|
31
|
+
const sprotty_vscode_webview_1 = require("sprotty-vscode-webview");
|
|
32
|
+
exports.receivedFromServerProperty = '__receivedFromServer';
|
|
33
|
+
exports.localDispatchProperty = '__localDispatch';
|
|
34
|
+
class GLSPVscodeDiagramServer extends sprotty_vscode_webview_1.VscodeDiagramServer {
|
|
35
|
+
initialize(registry) {
|
|
36
|
+
client_1.registerDefaultGLSPServerActions(registry, this);
|
|
37
|
+
this.clientId = this.viewerOptions.baseDiv;
|
|
38
|
+
window.addEventListener('message', message => {
|
|
39
|
+
if ('data' in message && sprotty_vscode_webview_1.isActionMessage(message.data)) {
|
|
40
|
+
this.messageReceived(message.data);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
window.addEventListener('copy', (e) => {
|
|
44
|
+
this.copyPasteHandler.handleCopy(e);
|
|
45
|
+
});
|
|
46
|
+
window.addEventListener('cut', (e) => {
|
|
47
|
+
this.copyPasteHandler.handleCut(e);
|
|
48
|
+
});
|
|
49
|
+
window.addEventListener('paste', (e) => {
|
|
50
|
+
this.copyPasteHandler.handlePaste(e);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
handleLocally(action) {
|
|
54
|
+
if (client_1.isSetEditModeAction(action)) {
|
|
55
|
+
return this.handleSetEditModeAction(action);
|
|
56
|
+
}
|
|
57
|
+
if (client_1.isDeleteElementOperation(action)) {
|
|
58
|
+
return this.handleDeleteElementOperation(action);
|
|
59
|
+
}
|
|
60
|
+
return super.handleLocally(action);
|
|
61
|
+
}
|
|
62
|
+
messageReceived(data) {
|
|
63
|
+
const object = typeof data === 'string' ? JSON.parse(data) : data;
|
|
64
|
+
if (sprotty_vscode_webview_1.isActionMessage(object) && object.action) {
|
|
65
|
+
if (!object.clientId || object.clientId === this.clientId) {
|
|
66
|
+
this.checkMessageOrigin(object);
|
|
67
|
+
this.logger.log(this, 'receiving', object);
|
|
68
|
+
this.actionDispatcher.dispatch(object.action).then(() => {
|
|
69
|
+
this.storeNewModel(object.action);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this.logger.error(this, 'received data is not an action message', object);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
checkMessageOrigin(message) {
|
|
78
|
+
const isLocalDispatch = message[exports.localDispatchProperty] || false;
|
|
79
|
+
if (!isLocalDispatch) {
|
|
80
|
+
message.action[exports.receivedFromServerProperty] = true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
handleComputedBounds(action) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
handleDeleteElementOperation(operation) {
|
|
87
|
+
if (operation.elementIds.length === 0) {
|
|
88
|
+
operation.elementIds.push(...this.selectionService.getSelectedElementIDs());
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
handleSetEditModeAction(action) {
|
|
93
|
+
return action[exports.receivedFromServerProperty] !== true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
__decorate([
|
|
97
|
+
inversify_1.inject(client_1.GLSP_TYPES.SelectionService),
|
|
98
|
+
__metadata("design:type", selection_service_1.SelectionService)
|
|
99
|
+
], GLSPVscodeDiagramServer.prototype, "selectionService", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
inversify_1.inject(client_1.GLSP_TYPES.ICopyPasteHandler),
|
|
102
|
+
__metadata("design:type", Object)
|
|
103
|
+
], GLSPVscodeDiagramServer.prototype, "copyPasteHandler", void 0);
|
|
104
|
+
exports.GLSPVscodeDiagramServer = GLSPVscodeDiagramServer;
|
|
105
|
+
//# sourceMappingURL=glsp-vscode-diagramserver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glsp-vscode-diagramserver.js","sourceRoot":"","sources":["../src/glsp-vscode-diagramserver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,iDAY8B;AAC9B,kGAA8F;AAC9F,yCAAmC;AACnC,mEAA8E;AAEjE,QAAA,0BAA0B,GAAG,sBAAsB,CAAC;AACpD,QAAA,qBAAqB,GAAG,iBAAiB,CAAC;AAEvD,MAAa,uBAAwB,SAAQ,4CAAmB;IAI5D,UAAU,CAAC,QAA+B;QACtC,yCAAgC,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;QAC3C,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE;YACzC,IAAI,MAAM,IAAI,OAAO,IAAI,wCAAe,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACpD,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aACtC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAiB,EAAE,EAAE;YAClD,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC,CAAiB,EAAE,EAAE;YACjD,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAiB,EAAE,EAAE;YACnD,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACP,CAAC;IAED,aAAa,CAAC,MAAc;QACxB,IAAI,4BAAmB,CAAC,MAAM,CAAC,EAAE;YAC7B,OAAO,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;SAC/C;QACD,IAAI,iCAAwB,CAAC,MAAM,CAAC,EAAE;YAClC,OAAO,IAAI,CAAC,4BAA4B,CAAC,MAAM,CAAC,CAAC;SACpD;QACD,OAAO,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAES,eAAe,CAAC,IAAS;QAC/B,MAAM,MAAM,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAClE,IAAI,wCAAe,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE;YAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ,EAAE;gBACvD,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;gBAChC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;gBAC3C,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;oBACpD,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBACtC,CAAC,CAAC,CAAC;aACN;SACJ;aAAM;YACH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,wCAAwC,EAAE,MAAM,CAAC,CAAC;SAC7E;IACL,CAAC;IAES,kBAAkB,CAAC,OAAsB;QAC/C,MAAM,eAAe,GAAI,OAAe,CAAC,6BAAqB,CAAC,IAAI,KAAK,CAAC;QACzE,IAAI,CAAC,eAAe,EAAE;YACjB,OAAO,CAAC,MAAc,CAAC,kCAA0B,CAAC,GAAG,IAAI,CAAC;SAC9D;IACL,CAAC;IAES,oBAAoB,CAAC,MAA4B;QACvD,OAAO,IAAI,CAAC;IAChB,CAAC;IAES,4BAA4B,CAAC,SAAiC;QACpE,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YACnC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,CAAC,CAAC;SAC/E;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAES,uBAAuB,CAAC,MAAyB;QACvD,OAAQ,MAAc,CAAC,kCAA0B,CAAC,KAAK,IAAI,CAAC;IAChE,CAAC;CACJ;AAvEwC;IAApC,kBAAM,CAAC,mBAAU,CAAC,gBAAgB,CAAC;8BAA6B,oCAAgB;iEAAC;AAC5C;IAArC,kBAAM,CAAC,mBAAU,CAAC,iBAAiB,CAAC;;iEAA+C;AAFxF,0DAwEC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2020 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
export * from './glsp-starter';
|
|
17
|
+
export * from './glsp-vscode-diagramserver';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
/********************************************************************************
|
|
14
|
+
* Copyright (c) 2020 EclipseSource and others.
|
|
15
|
+
*
|
|
16
|
+
* This program and the accompanying materials are made available under the
|
|
17
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
18
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
19
|
+
*
|
|
20
|
+
* This Source Code may also be made available under the following Secondary
|
|
21
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
22
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
23
|
+
* with the GNU Classpath Exception which is available at
|
|
24
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
25
|
+
*
|
|
26
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
27
|
+
********************************************************************************/
|
|
28
|
+
__exportStar(require("./glsp-starter"), exports);
|
|
29
|
+
__exportStar(require("./glsp-vscode-diagramserver"), exports);
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,iDAA+B;AAC/B,8DAA4C"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eclipse-glsp/vscode-integration-webview",
|
|
3
|
+
"version": "0.9.0-next.11de3de8",
|
|
4
|
+
"description": "Integration of a GLSP diagram in a VS Code extensions (WebView part)",
|
|
5
|
+
"license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"vscode",
|
|
8
|
+
"graph",
|
|
9
|
+
"diagram",
|
|
10
|
+
"layout",
|
|
11
|
+
"glsp"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://www.eclipse.org/glsp/",
|
|
14
|
+
"bugs": "https://github.com/eclipse-glsp/glsp/issues",
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Eclipse GLSP"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/eclipse-glsp/glsp-vscode-integration.git"
|
|
21
|
+
},
|
|
22
|
+
"contributors": [
|
|
23
|
+
{
|
|
24
|
+
"name": "Eclipse GLSP Project",
|
|
25
|
+
"email": "glsp-dev@eclipse.org",
|
|
26
|
+
"url": "https://projects.eclipse.org/projects/ecd.glsp"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"files": [
|
|
30
|
+
"lib",
|
|
31
|
+
"src",
|
|
32
|
+
"css"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@eclipse-glsp/client": "next",
|
|
36
|
+
"reflect-metadata": "^0.1.12",
|
|
37
|
+
"sprotty-vscode-webview": "0.1.2"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"rimraf": "latest",
|
|
41
|
+
"typescript": "latest"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"prepare": "yarn clean && yarn build && yarn lint",
|
|
45
|
+
"clean": "rimraf lib",
|
|
46
|
+
"build": "tsc",
|
|
47
|
+
"watch": "tsc -w",
|
|
48
|
+
"lint": "eslint -c ./.eslintrc.js --ext .ts ./src"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"main": "lib/index",
|
|
54
|
+
"types": "lib/index"
|
|
55
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2021 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import { Action, ActionHandlerRegistry, IActionHandler, IActionHandlerInitializer, ICommand } from 'sprotty';
|
|
17
|
+
import { SprottyDiagramIdentifier } from 'sprotty-vscode-webview';
|
|
18
|
+
import { vscodeApi } from 'sprotty-vscode-webview/lib/vscode-api';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Delegates actions that should be handled inside of the glsp vscode extension instead
|
|
22
|
+
* of the webview. This enables the implementation of action handlers that require access
|
|
23
|
+
* to the vscode API and/or node backend.
|
|
24
|
+
*/
|
|
25
|
+
export class GLSPVscodeExtensionActionHandler implements IActionHandler, IActionHandlerInitializer {
|
|
26
|
+
constructor(protected readonly actionKinds: string[], protected readonly diagramIdentifier: SprottyDiagramIdentifier) {}
|
|
27
|
+
|
|
28
|
+
initialize(registry: ActionHandlerRegistry): void {
|
|
29
|
+
this.actionKinds.forEach(kind => registry.register(kind, this));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
handle(action: Action): void | Action | ICommand {
|
|
33
|
+
if (this.actionKinds.includes(action.kind)) {
|
|
34
|
+
const message = {
|
|
35
|
+
clientId: this.diagramIdentifier.clientId,
|
|
36
|
+
action,
|
|
37
|
+
__localDispatch: true
|
|
38
|
+
};
|
|
39
|
+
vscodeApi.postMessage(message);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2020-2021 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import { DiagramServer, ExportSvgAction, NavigateToExternalTargetAction, SelectAction, TYPES } from '@eclipse-glsp/client';
|
|
17
|
+
import { RequestClipboardDataAction, SetClipboardDataAction } from '@eclipse-glsp/client/lib/features/copy-paste/copy-paste-actions';
|
|
18
|
+
import { Container } from 'inversify';
|
|
19
|
+
import {
|
|
20
|
+
SprottyDiagramIdentifier,
|
|
21
|
+
SprottyStarter,
|
|
22
|
+
VscodeDiagramServer,
|
|
23
|
+
VscodeDiagramWidget,
|
|
24
|
+
VscodeDiagramWidgetFactory
|
|
25
|
+
} from 'sprotty-vscode-webview';
|
|
26
|
+
import { GLSPVscodeExtensionActionHandler } from './extension-action-handler';
|
|
27
|
+
import { GLSPVscodeDiagramWidget } from './glsp-vscode-diagram-widget';
|
|
28
|
+
import { GLSPVscodeDiagramServer } from './glsp-vscode-diagramserver';
|
|
29
|
+
|
|
30
|
+
export abstract class GLSPStarter extends SprottyStarter {
|
|
31
|
+
protected addVscodeBindings(container: Container, diagramIdentifier: SprottyDiagramIdentifier): void {
|
|
32
|
+
container.bind(GLSPVscodeDiagramWidget).toSelf().inSingletonScope();
|
|
33
|
+
container.bind(VscodeDiagramWidget).toService(GLSPVscodeDiagramWidget);
|
|
34
|
+
container
|
|
35
|
+
.bind(VscodeDiagramWidgetFactory)
|
|
36
|
+
.toFactory(context => () => context.container.get<GLSPVscodeDiagramWidget>(GLSPVscodeDiagramWidget));
|
|
37
|
+
container.bind(SprottyDiagramIdentifier).toConstantValue(diagramIdentifier);
|
|
38
|
+
container.bind(GLSPVscodeDiagramServer).toSelf().inSingletonScope();
|
|
39
|
+
container.bind(VscodeDiagramServer).toService(GLSPVscodeDiagramServer);
|
|
40
|
+
container.bind(TYPES.ModelSource).toService(GLSPVscodeDiagramServer);
|
|
41
|
+
container.bind(DiagramServer).toService(GLSPVscodeDiagramServer);
|
|
42
|
+
|
|
43
|
+
this.configureExtensionActionHandler(container, diagramIdentifier);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
protected configureExtensionActionHandler(container: Container, diagramIdentifier: SprottyDiagramIdentifier): void {
|
|
47
|
+
const extensionActionHandler = new GLSPVscodeExtensionActionHandler(this.extensionActionKinds, diagramIdentifier);
|
|
48
|
+
container.bind(GLSPVscodeExtensionActionHandler).toConstantValue(extensionActionHandler);
|
|
49
|
+
container.bind(TYPES.IActionHandlerInitializer).toService(GLSPVscodeExtensionActionHandler);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* All kinds of actions that should (also) be delegated to and handled by the vscode extension
|
|
54
|
+
*/
|
|
55
|
+
protected get extensionActionKinds(): string[] {
|
|
56
|
+
return [
|
|
57
|
+
NavigateToExternalTargetAction.KIND,
|
|
58
|
+
RequestClipboardDataAction.KIND,
|
|
59
|
+
SetClipboardDataAction.KIND,
|
|
60
|
+
SelectAction.KIND,
|
|
61
|
+
ExportSvgAction.KIND
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2020-2021 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import {
|
|
17
|
+
DiagramServer,
|
|
18
|
+
EnableToolPaletteAction,
|
|
19
|
+
InitializeClientSessionAction,
|
|
20
|
+
RequestModelAction,
|
|
21
|
+
RequestTypeHintsAction
|
|
22
|
+
} from '@eclipse-glsp/client';
|
|
23
|
+
import { injectable } from 'inversify';
|
|
24
|
+
import { VscodeDiagramWidget } from 'sprotty-vscode-webview';
|
|
25
|
+
|
|
26
|
+
@injectable()
|
|
27
|
+
export abstract class GLSPVscodeDiagramWidget extends VscodeDiagramWidget {
|
|
28
|
+
protected initializeSprotty(): void {
|
|
29
|
+
if (this.modelSource instanceof DiagramServer) {
|
|
30
|
+
this.modelSource.clientId = this.diagramIdentifier.clientId;
|
|
31
|
+
}
|
|
32
|
+
this.actionDispatcher.dispatch(new InitializeClientSessionAction(this.diagramIdentifier.clientId));
|
|
33
|
+
this.actionDispatcher.dispatch(
|
|
34
|
+
new RequestModelAction({
|
|
35
|
+
sourceUri: decodeURI(this.diagramIdentifier.uri),
|
|
36
|
+
diagramType: this.diagramIdentifier.diagramType
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
this.actionDispatcher.dispatch(new RequestTypeHintsAction(this.diagramIdentifier.diagramType));
|
|
41
|
+
this.actionDispatcher.dispatch(new EnableToolPaletteAction());
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function decodeURI(uri: string): string {
|
|
46
|
+
return decodeURIComponent(uri.replace(/\+/g, ' '));
|
|
47
|
+
}
|