@eclipse-glsp/theia-integration
Version:
Glue code to integrate GLSP clients into Eclipse Theia
104 lines • 5.24 kB
JavaScript
;
/********************************************************************************
* Copyright (c) 2017-2018 TypeFox and others.
* Modifications: (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
********************************************************************************/
// based on: https://github.com/eclipse-sprotty/sprotty-theia/blob/v0.12.0/src/theia/diagram-commands.ts
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var GLSPDiagramKeybindingContext_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GLSPDiagramKeybindingContribution = exports.GLSPDiagramKeybindingContext = void 0;
const browser_1 = require("@theia/core/lib/browser");
const frontend_application_1 = require("@theia/core/lib/browser/frontend-application");
const inversify_1 = require("inversify");
const glsp_diagram_commands_1 = require("./glsp-diagram-commands");
const glsp_diagram_widget_1 = require("./glsp-diagram-widget");
let GLSPDiagramKeybindingContext = GLSPDiagramKeybindingContext_1 = class GLSPDiagramKeybindingContext {
constructor() {
this.id = GLSPDiagramKeybindingContext_1.ID;
}
isEnabled(_arg) {
return !!(0, glsp_diagram_widget_1.getDiagramWidget)(this.application.shell);
}
};
exports.GLSPDiagramKeybindingContext = GLSPDiagramKeybindingContext;
GLSPDiagramKeybindingContext.ID = 'glsp.diagram.keybinding.context';
__decorate([
(0, inversify_1.inject)(frontend_application_1.FrontendApplication),
__metadata("design:type", frontend_application_1.FrontendApplication)
], GLSPDiagramKeybindingContext.prototype, "application", void 0);
exports.GLSPDiagramKeybindingContext = GLSPDiagramKeybindingContext = GLSPDiagramKeybindingContext_1 = __decorate([
(0, inversify_1.injectable)()
], GLSPDiagramKeybindingContext);
let GLSPDiagramKeybindingContribution = class GLSPDiagramKeybindingContribution {
registerKeybindings(registry) {
[
{
command: glsp_diagram_commands_1.GLSPDiagramCommands.CENTER,
context: this.diagramKeybindingContext.id,
keybinding: 'alt+c'
},
{
command: glsp_diagram_commands_1.GLSPDiagramCommands.FIT,
context: this.diagramKeybindingContext.id,
keybinding: 'alt+f'
},
{
command: glsp_diagram_commands_1.GLSPDiagramCommands.EXPORT,
context: this.diagramKeybindingContext.id,
keybinding: 'alt+e'
},
{
command: glsp_diagram_commands_1.GLSPDiagramCommands.LAYOUT,
context: this.diagramKeybindingContext.id,
keybinding: 'alt+l'
},
{
command: glsp_diagram_commands_1.GLSPDiagramCommands.SELECT_ALL,
context: this.diagramKeybindingContext.id,
keybinding: 'ctrlcmd+a'
},
{
command: browser_1.CommonCommands.UNDO.id,
context: this.diagramKeybindingContext.id,
keybinding: 'ctrlcmd+z'
},
{
command: browser_1.CommonCommands.REDO.id,
context: this.diagramKeybindingContext.id,
keybinding: 'ctrlcmd+shift+z'
}
].forEach(binding => {
registry.registerKeybinding(binding);
});
}
};
exports.GLSPDiagramKeybindingContribution = GLSPDiagramKeybindingContribution;
__decorate([
(0, inversify_1.inject)(GLSPDiagramKeybindingContext),
__metadata("design:type", GLSPDiagramKeybindingContext)
], GLSPDiagramKeybindingContribution.prototype, "diagramKeybindingContext", void 0);
exports.GLSPDiagramKeybindingContribution = GLSPDiagramKeybindingContribution = __decorate([
(0, inversify_1.injectable)()
], GLSPDiagramKeybindingContribution);
//# sourceMappingURL=glsp-diagram-keybinding.js.map