UNPKG

@eclipse-glsp/protocol

Version:

The protocol definition for client-server communication in GLSP

71 lines 3.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SelectAllAction = exports.SelectAction = void 0; const array_util_1 = require("../utils/array-util"); const type_util_1 = require("../utils/type-util"); const base_protocol_1 = require("./base-protocol"); var SelectAction; (function (SelectAction) { SelectAction.KIND = 'elementSelected'; function is(object) { return base_protocol_1.Action.hasKind(object, SelectAction.KIND) && (0, type_util_1.hasArrayProp)(object, 'selectedElementsIDs') && (0, type_util_1.hasArrayProp)(object, 'deselectedElementsIDs'); } SelectAction.is = is; function create(options = {}) { var _a, _b; const deselectedElementsIDs = (_a = options.deselectedElementsIDs) !== null && _a !== void 0 ? _a : []; return { kind: SelectAction.KIND, selectedElementsIDs: (_b = options.selectedElementsIDs) !== null && _b !== void 0 ? _b : [], deselectedElementsIDs: (0, array_util_1.isStringArray)(deselectedElementsIDs, true) ? deselectedElementsIDs : [], deselectAll: typeof deselectedElementsIDs === 'boolean' ? deselectedElementsIDs : false }; } SelectAction.create = create; /** * Creates a new {@link SelectAction} to add the given elements to the existing selection. * @param selectedElementsIDs The identifiers of the elements to add to the selection. * @returns the corresponding {@link SelectAction} */ function addSelection(selectedElementsIDs) { return create({ selectedElementsIDs }); } SelectAction.addSelection = addSelection; /** * Creates a new {@link SelectAction} * to remove the given elements from the existing selection. * @param deselectedElementsIDs The identifiers of the elements to remove from the selection. * @return the corresponding {@link SelectAction} */ function removeSelection(deselectedElementsIDs) { return create({ deselectedElementsIDs }); } SelectAction.removeSelection = removeSelection; /** * Creates a new {@link SelectAction} * to set the selection to the given elements. * This replaces the current selection with the given elements. * @param selectedElementsIDs The identifiers of the elements to select. * @returns the corresponding {@link SelectAction} */ function setSelection(selectedElementsIDs) { return create({ selectedElementsIDs, deselectedElementsIDs: true }); } SelectAction.setSelection = setSelection; })(SelectAction || (exports.SelectAction = SelectAction = {})); var SelectAllAction; (function (SelectAllAction) { SelectAllAction.KIND = 'allSelected'; function is(object) { return base_protocol_1.Action.hasKind(object, SelectAllAction.KIND) && (0, type_util_1.hasBooleanProp)(object, 'select'); } SelectAllAction.is = is; function create(select = true) { return { kind: SelectAllAction.KIND, select }; } SelectAllAction.create = create; })(SelectAllAction || (exports.SelectAllAction = SelectAllAction = {})); //# sourceMappingURL=element-selection.js.map