UNPKG

@eclipse-glsp/client

Version:

A sprotty-based client for GLSP

50 lines 2.9 kB
"use strict"; 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; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.toolFocusLossModule = exports.EnableDefaultToolsOnFocusLossHandler = void 0; /******************************************************************************** * Copyright (c) 2022-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 sprotty_1 = require("@eclipse-glsp/sprotty"); const inversify_1 = require("inversify"); const focus_state_change_action_1 = require("../../base/focus/focus-state-change-action"); const tool_1 = require("../../base/tool-manager/tool"); /** * Action handler that enables the default tools when the diagram lost focus. * @see FocusStateChangedAction */ let EnableDefaultToolsOnFocusLossHandler = class EnableDefaultToolsOnFocusLossHandler { handle(action) { if (focus_state_change_action_1.FocusStateChangedAction.is(action) && !action.hasFocus) { return tool_1.EnableDefaultToolsAction.create(); } } }; exports.EnableDefaultToolsOnFocusLossHandler = EnableDefaultToolsOnFocusLossHandler; exports.EnableDefaultToolsOnFocusLossHandler = EnableDefaultToolsOnFocusLossHandler = __decorate([ (0, inversify_1.injectable)() ], EnableDefaultToolsOnFocusLossHandler); /** * Enables the default tools in the tool manager if the diagram looses focus. */ exports.toolFocusLossModule = new sprotty_1.FeatureModule((bind, _unbind, isBound) => { (0, sprotty_1.configureActionHandler)({ bind, isBound }, focus_state_change_action_1.FocusStateChangedAction.KIND, EnableDefaultToolsOnFocusLossHandler); }, { featureId: Symbol('toolFocusLoss ') }); //# sourceMappingURL=tool-focus-loss-module.js.map