UNPKG

@eclipse-glsp/client

Version:

A sprotty-based client for GLSP

129 lines 7.6 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; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.MoveFinishedEventAction = exports.MoveInitializedEventAction = exports.HideChangeBoundsToolResizeFeedbackCommand = exports.ShowChangeBoundsToolResizeFeedbackCommand = exports.HideChangeBoundsToolResizeFeedbackAction = exports.ShowChangeBoundsToolResizeFeedbackAction = void 0; /******************************************************************************** * Copyright (c) 2019-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 feedback_command_1 = require("../../../base/feedback/feedback-command"); const glsp_model_source_1 = require("../../../base/model/glsp-model-source"); const gmodel_util_1 = require("../../../utils/gmodel-util"); const model_1 = require("../../change-bounds/model"); var ShowChangeBoundsToolResizeFeedbackAction; (function (ShowChangeBoundsToolResizeFeedbackAction) { ShowChangeBoundsToolResizeFeedbackAction.KIND = 'showChangeBoundsToolResizeFeedback'; function is(object) { return sprotty_1.Action.hasKind(object, ShowChangeBoundsToolResizeFeedbackAction.KIND) && (0, sprotty_1.hasStringProp)(object, 'elementId'); } ShowChangeBoundsToolResizeFeedbackAction.is = is; function create(options) { const opts = typeof options === 'string' ? { elementId: options } : options; return { kind: ShowChangeBoundsToolResizeFeedbackAction.KIND, ...opts }; } ShowChangeBoundsToolResizeFeedbackAction.create = create; })(ShowChangeBoundsToolResizeFeedbackAction || (exports.ShowChangeBoundsToolResizeFeedbackAction = ShowChangeBoundsToolResizeFeedbackAction = {})); var HideChangeBoundsToolResizeFeedbackAction; (function (HideChangeBoundsToolResizeFeedbackAction) { HideChangeBoundsToolResizeFeedbackAction.KIND = 'hideChangeBoundsToolResizeFeedback'; function is(object) { return sprotty_1.Action.hasKind(object, HideChangeBoundsToolResizeFeedbackAction.KIND); } HideChangeBoundsToolResizeFeedbackAction.is = is; function create() { return { kind: HideChangeBoundsToolResizeFeedbackAction.KIND }; } HideChangeBoundsToolResizeFeedbackAction.create = create; })(HideChangeBoundsToolResizeFeedbackAction || (exports.HideChangeBoundsToolResizeFeedbackAction = HideChangeBoundsToolResizeFeedbackAction = {})); let ShowChangeBoundsToolResizeFeedbackCommand = class ShowChangeBoundsToolResizeFeedbackCommand extends feedback_command_1.FeedbackCommand { execute(context) { var _a, _b; const index = context.root.index; (0, gmodel_util_1.forEachElement)(index, model_1.isResizable, element => element.id !== this.action.elementId && (0, model_1.removeResizeHandles)(element)); if (this.action.elementId) { const resizeElement = index.getById(this.action.elementId); if (resizeElement && (0, model_1.isResizable)(resizeElement)) { (0, model_1.addResizeHandles)(resizeElement, (_b = (_a = this.action.resizeLocations) !== null && _a !== void 0 ? _a : resizeElement.resizeLocations) !== null && _b !== void 0 ? _b : this.changeBoundsManager.defaultResizeLocations()); } } return context.root; } }; exports.ShowChangeBoundsToolResizeFeedbackCommand = ShowChangeBoundsToolResizeFeedbackCommand; ShowChangeBoundsToolResizeFeedbackCommand.KIND = ShowChangeBoundsToolResizeFeedbackAction.KIND; __decorate([ (0, inversify_1.inject)(sprotty_1.TYPES.Action), __metadata("design:type", Object) ], ShowChangeBoundsToolResizeFeedbackCommand.prototype, "action", void 0); __decorate([ (0, inversify_1.inject)(sprotty_1.TYPES.IChangeBoundsManager), __metadata("design:type", Object) ], ShowChangeBoundsToolResizeFeedbackCommand.prototype, "changeBoundsManager", void 0); exports.ShowChangeBoundsToolResizeFeedbackCommand = ShowChangeBoundsToolResizeFeedbackCommand = __decorate([ (0, inversify_1.injectable)() ], ShowChangeBoundsToolResizeFeedbackCommand); let HideChangeBoundsToolResizeFeedbackCommand = class HideChangeBoundsToolResizeFeedbackCommand extends feedback_command_1.FeedbackCommand { execute(context) { const index = context.root.index; (0, gmodel_util_1.forEachElement)(index, model_1.isResizable, model_1.removeResizeHandles); return context.root; } }; exports.HideChangeBoundsToolResizeFeedbackCommand = HideChangeBoundsToolResizeFeedbackCommand; HideChangeBoundsToolResizeFeedbackCommand.KIND = HideChangeBoundsToolResizeFeedbackAction.KIND; __decorate([ (0, inversify_1.inject)(sprotty_1.TYPES.Action), __metadata("design:type", Object) ], HideChangeBoundsToolResizeFeedbackCommand.prototype, "action", void 0); exports.HideChangeBoundsToolResizeFeedbackCommand = HideChangeBoundsToolResizeFeedbackCommand = __decorate([ (0, inversify_1.injectable)() ], HideChangeBoundsToolResizeFeedbackCommand); var MoveInitializedEventAction; (function (MoveInitializedEventAction) { MoveInitializedEventAction.KIND = 'move-initialized-event'; function is(object) { return sprotty_1.Action.hasKind(object, MoveInitializedEventAction.KIND); } MoveInitializedEventAction.is = is; function create() { return glsp_model_source_1.OptionalAction.mark({ kind: MoveInitializedEventAction.KIND }); } MoveInitializedEventAction.create = create; })(MoveInitializedEventAction || (exports.MoveInitializedEventAction = MoveInitializedEventAction = {})); var MoveFinishedEventAction; (function (MoveFinishedEventAction) { MoveFinishedEventAction.KIND = 'move-finished-event'; function is(object) { return sprotty_1.Action.hasKind(object, MoveFinishedEventAction.KIND); } MoveFinishedEventAction.is = is; function create() { return glsp_model_source_1.OptionalAction.mark({ kind: MoveFinishedEventAction.KIND }); } MoveFinishedEventAction.create = create; })(MoveFinishedEventAction || (exports.MoveFinishedEventAction = MoveFinishedEventAction = {})); //# sourceMappingURL=change-bounds-tool-feedback.js.map