@eclipse-glsp/theia-integration
Version:
Glue code to integrate GLSP clients into Eclipse Theia
113 lines • 6.84 kB
JavaScript
;
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 NavigateToMarkerMenuContribution_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.NavigateToMarkerKeybindingContribution = exports.NavigateToMarkerMenuContribution = exports.NavigateToMarkerCommandContribution = exports.NavigateToMarkerCommand = void 0;
exports.registerMarkerNavigationCommands = registerMarkerNavigationCommands;
/********************************************************************************
* Copyright (c) 2020-2024 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
********************************************************************************/
const lib_1 = require("@eclipse-glsp/client/lib");
const core_1 = require("@theia/core");
const browser_1 = require("@theia/core/lib/browser");
const inversify_1 = require("@theia/core/shared/inversify");
const glsp_command_handler_1 = require("./diagram/glsp-command-handler");
const glsp_diagram_keybinding_1 = require("./diagram/glsp-diagram-keybinding");
const theia_context_menu_service_1 = require("./diagram/theia-context-menu-service");
function registerMarkerNavigationCommands(context) {
if (!context.isBound(NavigateToMarkerCommandContribution)) {
(0, lib_1.bindAsService)(context, core_1.CommandContribution, NavigateToMarkerCommandContribution);
}
if (!context.isBound(NavigateToMarkerMenuContribution)) {
(0, lib_1.bindAsService)(context, core_1.MenuContribution, NavigateToMarkerMenuContribution);
}
if (!context.isBound(NavigateToMarkerKeybindingContribution)) {
(0, lib_1.bindAsService)(context, browser_1.KeybindingContribution, NavigateToMarkerKeybindingContribution);
}
}
var NavigateToMarkerCommand;
(function (NavigateToMarkerCommand) {
NavigateToMarkerCommand.NEXT_MARKER = 'next-marker';
NavigateToMarkerCommand.PREVIOUS_MARKER = 'previous-marker';
})(NavigateToMarkerCommand || (exports.NavigateToMarkerCommand = NavigateToMarkerCommand = {}));
let NavigateToMarkerCommandContribution = class NavigateToMarkerCommandContribution {
registerCommands(commands) {
commands.registerCommand({ id: NavigateToMarkerCommand.NEXT_MARKER, label: 'Go to Next Marker', category: 'Diagram' }, new glsp_command_handler_1.GLSPCommandHandler(this.shell, {
actions: () => [lib_1.NavigateToMarkerAction.create({ direction: 'next' })],
isEnabled: context => (0, lib_1.collectIssueMarkers)(context.modelRoot).length > 0
}));
commands.registerCommand({ id: NavigateToMarkerCommand.PREVIOUS_MARKER, label: 'Go to Previous Marker', category: 'Diagram' }, new glsp_command_handler_1.GLSPCommandHandler(this.shell, {
actions: () => [lib_1.NavigateToMarkerAction.create({ direction: 'previous' })],
isEnabled: context => (0, lib_1.collectIssueMarkers)(context.modelRoot).length > 0
}));
}
};
exports.NavigateToMarkerCommandContribution = NavigateToMarkerCommandContribution;
__decorate([
(0, inversify_1.inject)(browser_1.ApplicationShell),
__metadata("design:type", browser_1.ApplicationShell)
], NavigateToMarkerCommandContribution.prototype, "shell", void 0);
exports.NavigateToMarkerCommandContribution = NavigateToMarkerCommandContribution = __decorate([
(0, inversify_1.injectable)()
], NavigateToMarkerCommandContribution);
let NavigateToMarkerMenuContribution = NavigateToMarkerMenuContribution_1 = class NavigateToMarkerMenuContribution {
registerMenus(menus) {
menus.registerSubmenu(NavigateToMarkerMenuContribution_1.NAVIGATION, 'Go to');
menus.registerMenuAction(NavigateToMarkerMenuContribution_1.NAVIGATION.concat('m'), {
commandId: NavigateToMarkerCommand.NEXT_MARKER,
label: 'Next Marker'
});
menus.registerMenuAction(NavigateToMarkerMenuContribution_1.NAVIGATION.concat('m'), {
commandId: NavigateToMarkerCommand.PREVIOUS_MARKER,
label: 'Previous Marker'
});
}
};
exports.NavigateToMarkerMenuContribution = NavigateToMarkerMenuContribution;
NavigateToMarkerMenuContribution.NAVIGATION = theia_context_menu_service_1.GLSPContextMenu.MENU_PATH.concat('navigate');
exports.NavigateToMarkerMenuContribution = NavigateToMarkerMenuContribution = NavigateToMarkerMenuContribution_1 = __decorate([
(0, inversify_1.injectable)()
], NavigateToMarkerMenuContribution);
let NavigateToMarkerKeybindingContribution = class NavigateToMarkerKeybindingContribution {
registerKeybindings(keybindings) {
keybindings.registerKeybinding({
command: NavigateToMarkerCommand.NEXT_MARKER,
context: this.diagramKeybindingContext.id,
keybinding: 'f8'
});
keybindings.registerKeybinding({
command: NavigateToMarkerCommand.PREVIOUS_MARKER,
context: this.diagramKeybindingContext.id,
keybinding: 'shift+f8'
});
}
};
exports.NavigateToMarkerKeybindingContribution = NavigateToMarkerKeybindingContribution;
__decorate([
(0, inversify_1.inject)(glsp_diagram_keybinding_1.GLSPDiagramKeybindingContext),
__metadata("design:type", glsp_diagram_keybinding_1.GLSPDiagramKeybindingContext)
], NavigateToMarkerKeybindingContribution.prototype, "diagramKeybindingContext", void 0);
exports.NavigateToMarkerKeybindingContribution = NavigateToMarkerKeybindingContribution = __decorate([
(0, inversify_1.injectable)()
], NavigateToMarkerKeybindingContribution);
//# sourceMappingURL=theia-navigate-to-marker-contribution.js.map