New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@eclipse-glsp/client

Package Overview
Dependencies
Maintainers
4
Versions
378
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eclipse-glsp/client - npm Package Compare versions

Comparing version 0.8.0-next.13534ee to 0.8.0-next.1416c36

lib/features/command-palette/server-command-palette-provider.d.ts

1

lib/base/model/update-model-command.d.ts

@@ -6,3 +6,2 @@ import { Action, ActionHandlerRegistry, CommandExecutionContext, CommandReturn, IActionHandler, ILogger, SetModelAction, SModelRoot } from "sprotty/lib";

handle(action: Action): Action | void;
handledActionKinds: string[];
}

@@ -9,0 +8,0 @@ export declare function isSetModelAction(action: Action): action is SetModelAction;

@@ -52,3 +52,2 @@ "use strict";

function SetModelActionHandler() {
this.handledActionKinds = [lib_1.SetModelCommand.KIND];
}

@@ -55,0 +54,0 @@ SetModelActionHandler.prototype.handle = function (action) {

@@ -16,4 +16,7 @@ /********************************************************************************

********************************************************************************/
import { BoundsAware, Hoverable, Locateable, SChildElement, Selectable, SModelElement, SNode, SParentElement } from "sprotty/lib";
import { NodeEditConfig } from "../../base/edit-config/edit-config";
import { BoundsAware, Hoverable, Locateable, SChildElement, Selectable, SModelElement, SParentElement } from "sprotty/lib";
export declare const resizeFeature: unique symbol;
export interface Resizable extends BoundsAware, Selectable {
}
export declare function isResizable(element: SModelElement): element is SParentElement & Resizable;
export declare enum ResizeHandleLocation {

@@ -25,3 +28,2 @@ TopLeft = "top-left",

}
export declare function isResizeable(element: SModelElement): element is SNode & SParentElement & BoundsAware & Selectable & NodeEditConfig;
export declare function isBoundsAwareMoveable(element: SModelElement): element is SModelElement & Locateable & BoundsAware;

@@ -28,0 +30,0 @@ export declare class SResizeHandle extends SChildElement implements Hoverable {

@@ -32,3 +32,7 @@ "use strict";

var lib_1 = require("sprotty/lib");
var edit_config_1 = require("../../base/edit-config/edit-config");
exports.resizeFeature = Symbol("resizeFeature");
function isResizable(element) {
return lib_1.isBoundsAware(element) && lib_1.isSelectable(element) && element instanceof lib_1.SParentElement && element.hasFeature(exports.resizeFeature);
}
exports.isResizable = isResizable;
var ResizeHandleLocation;

@@ -41,6 +45,2 @@ (function (ResizeHandleLocation) {

})(ResizeHandleLocation = exports.ResizeHandleLocation || (exports.ResizeHandleLocation = {}));
function isResizeable(element) {
return edit_config_1.isConfigurableNode(element) && element.resizable && lib_1.isBoundsAware(element) && lib_1.isSelectable(element) && element instanceof lib_1.SParentElement;
}
exports.isResizeable = isResizeable;
function isBoundsAwareMoveable(element) {

@@ -47,0 +47,0 @@ return lib_1.isMoveable(element) && lib_1.isBoundsAware(element);

@@ -21,9 +21,7 @@ "use strict";

var lib_1 = require("sprotty/lib");
var action_provider_1 = require("./action-provider");
var glspCommandPaletteModule = new inversify_1.ContainerModule(function (bind, unbind, isBound, rebind) {
bind(lib_1.TYPES.ICommandPaletteActionProvider).to(action_provider_1.NavigationCommandPaletteActionProvider);
bind(action_provider_1.ServerCommandPaletteActionProvider).toSelf().inSingletonScope();
bind(lib_1.TYPES.ICommandPaletteActionProvider).to(action_provider_1.ServerCommandPaletteActionProvider);
var server_command_palette_provider_1 = require("./server-command-palette-provider");
var glspCommandPaletteModule = new inversify_1.ContainerModule(function (bind) {
bind(lib_1.TYPES.ICommandPaletteActionProvider).to(server_command_palette_provider_1.ServerCommandPaletteActionProvider);
});
exports.default = glspCommandPaletteModule;
//# sourceMappingURL=di.config.js.map

@@ -1,19 +0,21 @@

import { Action, EditableLabel, EditLabelValidationResult, IEditLabelValidationDecorator, IEditLabelValidator, SModelElement } from "sprotty";
import { RequestResponseSupport } from "../request-response/support";
export declare class ValidateLabelEditAction implements Action {
import { Action, EditableLabel, EditLabelValidationResult, IEditLabelValidationDecorator, IEditLabelValidator, RequestAction, ResponseAction, SModelElement } from "sprotty";
import { GLSPActionDispatcher } from "../request-response/glsp-action-dispatcher";
export declare class ValidateLabelEditAction implements RequestAction<SetLabelEditValidationResultAction> {
readonly value: string;
readonly labelId: string;
readonly requestId: string;
static readonly KIND = "validateLabelEdit";
kind: string;
constructor(value: string, labelId: string);
constructor(value: string, labelId: string, requestId?: string);
}
export declare class SetLabelEditValidationResultAction implements Action {
export declare class SetLabelEditValidationResultAction implements ResponseAction {
readonly result: EditLabelValidationResult;
readonly responseId: string;
static readonly KIND = "setLabelEditValidationResult";
kind: string;
constructor(result: EditLabelValidationResult);
constructor(result: EditLabelValidationResult, responseId?: string);
}
export declare function isSetLabelEditValidationResultAction(action: Action): action is SetLabelEditValidationResultAction;
export declare class ServerEditLabelValidator implements IEditLabelValidator {
protected requestResponseSupport: RequestResponseSupport;
protected actionDispatcher: GLSPActionDispatcher;
validate(value: string, label: EditableLabel & SModelElement): Promise<EditLabelValidationResult>;

@@ -20,0 +22,0 @@ getValidationResultFromResponse(action: Action): EditLabelValidationResult;

@@ -28,8 +28,10 @@ "use strict";

var inversify_1 = require("inversify");
var types_1 = require("../../types");
var support_1 = require("../request-response/support");
var sprotty_1 = require("sprotty");
var glsp_action_dispatcher_1 = require("../request-response/glsp-action-dispatcher");
var ValidateLabelEditAction = /** @class */ (function () {
function ValidateLabelEditAction(value, labelId) {
function ValidateLabelEditAction(value, labelId, requestId) {
if (requestId === void 0) { requestId = sprotty_1.generateRequestId(); }
this.value = value;
this.labelId = labelId;
this.requestId = requestId;
this.kind = ValidateLabelEditAction.KIND;

@@ -42,4 +44,6 @@ }

var SetLabelEditValidationResultAction = /** @class */ (function () {
function SetLabelEditValidationResultAction(result) {
function SetLabelEditValidationResultAction(result, responseId) {
if (responseId === void 0) { responseId = ''; }
this.result = result;
this.responseId = responseId;
this.kind = SetLabelEditValidationResultAction.KIND;

@@ -60,4 +64,5 @@ }

ServerEditLabelValidator.prototype.validate = function (value, label) {
var _this = this;
var action = new ValidateLabelEditAction(value, label.id);
return this.requestResponseSupport.dispatchRequest(action, this.getValidationResultFromResponse);
return this.actionDispatcher.requestUntil(action).then(function (response) { return _this.getValidationResultFromResponse(response); });
};

@@ -71,5 +76,5 @@ ServerEditLabelValidator.prototype.getValidationResultFromResponse = function (action) {

__decorate([
inversify_1.inject(types_1.GLSP_TYPES.RequestResponseSupport),
__metadata("design:type", support_1.RequestResponseSupport)
], ServerEditLabelValidator.prototype, "requestResponseSupport", void 0);
inversify_1.inject(sprotty_1.TYPES.IActionDispatcher),
__metadata("design:type", glsp_action_dispatcher_1.GLSPActionDispatcher)
], ServerEditLabelValidator.prototype, "actionDispatcher", void 0);
ServerEditLabelValidator = __decorate([

@@ -76,0 +81,0 @@ inversify_1.injectable()

@@ -21,11 +21,11 @@ "use strict";

var types_1 = require("../../types");
var action_definition_1 = require("./action-definition");
var type_hints_action_initializer_1 = require("./type-hints-action-initializer");
var request_type_hints_action_1 = require("./request-type-hints-action");
var type_hints_1 = require("./type-hints");
var modelHintsModule = new inversify_1.ContainerModule(function (bind, _unbind, isBound) {
bind(type_hints_action_initializer_1.TypeHintsEditConfigProvider).toSelf().inSingletonScope();
lib_1.configureActionHandler({ bind: bind, isBound: isBound }, action_definition_1.SetTypeHintsAction.KIND, type_hints_action_initializer_1.TypeHintsEditConfigProvider);
bind(types_1.GLSP_TYPES.IEditConfigProvider).toService(type_hints_action_initializer_1.TypeHintsEditConfigProvider);
lib_1.configureCommand({ bind: bind, isBound: isBound }, type_hints_action_initializer_1.ApplyEditConfigCommand);
bind(type_hints_1.TypeHintProvider).toSelf().inSingletonScope();
bind(types_1.GLSP_TYPES.ITypeHintProvider).toService(type_hints_1.TypeHintProvider);
lib_1.configureActionHandler({ bind: bind, isBound: isBound }, request_type_hints_action_1.SetTypeHintsAction.KIND, type_hints_1.TypeHintProvider);
lib_1.configureCommand({ bind: bind, isBound: isBound }, type_hints_1.ApplyTypeHintsCommand);
});
exports.default = modelHintsModule;
//# sourceMappingURL=di.config.js.map

@@ -53,5 +53,5 @@ import { Action, Command, CommandExecutionContext, CommandReturn, Dimension, ElementAndBounds, ElementMove, IActionDispatcher, KeyListener, Point, SModelElement } from "sprotty";

export declare namespace Select {
function all(elements: SelectableBoundsAware[]): SelectableBoundsAware[];
function first(elements: SelectableBoundsAware[]): SelectableBoundsAware[];
function last(elements: SelectableBoundsAware[]): SelectableBoundsAware[];
function all(elements: SelectableBoundsAware[]): (SModelElement & import("sprotty").BoundsAware & import("sprotty").Selectable)[];
function first(elements: SelectableBoundsAware[]): (SModelElement & import("sprotty").BoundsAware & import("sprotty").Selectable)[];
function last(elements: SelectableBoundsAware[]): (SModelElement & import("sprotty").BoundsAware & import("sprotty").Selectable)[];
}

@@ -58,0 +58,0 @@ export declare class AlignElementsAction implements Action {

@@ -16,6 +16,8 @@ /********************************************************************************

********************************************************************************/
import { RoutingHandleKind, SModelElement, SRoutableElement, SRoutingHandle } from "sprotty/lib";
export declare function isRoutable<T extends SModelElement>(element: T): element is T & SRoutableElement;
import { RoutingHandleKind, SModelElement, SModelExtension, SRoutableElement, SRoutingHandle } from "sprotty/lib";
export declare const reconnectFeature: unique symbol;
export interface Reconnectable extends SModelExtension {
}
export declare function isReconnectable(element: SModelElement): element is SRoutableElement & Reconnectable;
export declare function isReconnectHandle(element: SModelElement | undefined): element is SReconnectHandle;
export declare function isRoutingHandle(element: SModelElement | undefined): element is SRoutingHandle;
export declare function addReconnectHandles(element: SRoutableElement): void;

@@ -22,0 +24,0 @@ export declare function removeReconnectHandles(element: SRoutableElement): void;

@@ -32,7 +32,8 @@ "use strict";

var lib_1 = require("sprotty/lib");
exports.reconnectFeature = Symbol("reconnectFeature");
function isReconnectable(element) {
return element instanceof lib_1.SRoutableElement && element.hasFeature(exports.reconnectFeature);
}
exports.isReconnectable = isReconnectable;
var ROUTING_HANDLE_SOURCE_INDEX = -2;
function isRoutable(element) {
return element instanceof lib_1.SRoutableElement && element.routingPoints !== undefined;
}
exports.isRoutable = isRoutable;
function isReconnectHandle(element) {

@@ -42,6 +43,2 @@ return element !== undefined && element instanceof SReconnectHandle;

exports.isReconnectHandle = isReconnectHandle;
function isRoutingHandle(element) {
return element !== undefined && element instanceof lib_1.SRoutingHandle;
}
exports.isRoutingHandle = isRoutingHandle;
function addReconnectHandles(element) {

@@ -48,0 +45,0 @@ removeReconnectHandles(element);

@@ -20,10 +20,7 @@ "use strict";

var sprotty_1 = require("sprotty");
var types_1 = require("../../types");
var support_1 = require("./support");
var glsp_action_dispatcher_1 = require("./glsp-action-dispatcher");
var requestResponseModule = new inversify_1.ContainerModule(function (bind, unbind, isBound, rebind) {
bind(support_1.RequestResponseSupport).toSelf().inSingletonScope();
bind(types_1.GLSP_TYPES.RequestResponseSupport).toService(support_1.RequestResponseSupport);
bind(sprotty_1.TYPES.IActionHandlerInitializer).toService(support_1.RequestResponseSupport);
rebind(sprotty_1.TYPES.IActionDispatcher).to(glsp_action_dispatcher_1.GLSPActionDispatcher).inSingletonScope();
});
exports.default = requestResponseModule;
//# sourceMappingURL=di.config.js.map

@@ -73,6 +73,6 @@ "use strict";

var index = context.root.index;
index.all().filter(model_1.isResizeable).forEach(model_1.removeResizeHandles);
index.all().filter(model_1.isResizable).forEach(model_1.removeResizeHandles);
if (smodel_util_1.isNotUndefined(this.action.elementId)) {
var resizeElement = index.getById(this.action.elementId);
if (smodel_util_1.isNotUndefined(resizeElement) && model_1.isResizeable(resizeElement)) {
if (smodel_util_1.isNotUndefined(resizeElement) && model_1.isResizable(resizeElement)) {
model_1.addResizeHandles(resizeElement);

@@ -101,3 +101,3 @@ }

var index = context.root.index;
index.all().filter(model_1.isResizeable).forEach(model_1.removeResizeHandles);
index.all().filter(model_1.isResizable).forEach(model_1.removeResizeHandles);
return context.root;

@@ -130,3 +130,3 @@ };

FeedbackMoveMouseListener.prototype.mouseDown = function (target, event) {
if (event.button === 0) {
if (event.button === 0 && !(target instanceof model_1.SResizeHandle)) {
var moveable = lib_1.findParentByFeature(target, lib_1.isMoveable);

@@ -133,0 +133,0 @@ if (moveable !== undefined) {

@@ -6,4 +6,5 @@ import { Action, AnchorComputerRegistry, CommandExecutionContext, CommandReturn, MouseListener, SDanglingAnchor, SModelElement, SModelRoot, SRoutableElement } from "sprotty/lib";

readonly sourceId: string;
readonly routerKind?: string | undefined;
kind: string;
constructor(elementTypeId: string, sourceId: string);
constructor(elementTypeId: string, sourceId: string, routerKind?: string | undefined);
}

@@ -10,0 +11,0 @@ export declare class DrawFeedbackEdgeCommand extends FeedbackCommand {

@@ -45,9 +45,10 @@ "use strict";

var lib_1 = require("sprotty/lib");
var smodel_util_1 = require("../../utils/smodel-util");
var viewpoint_util_1 = require("../../utils/viewpoint-util");
var model_1 = require("../reconnect/model");
var model_2 = require("./model");
var model_1 = require("./model");
var DrawFeedbackEdgeAction = /** @class */ (function () {
function DrawFeedbackEdgeAction(elementTypeId, sourceId) {
function DrawFeedbackEdgeAction(elementTypeId, sourceId, routerKind) {
this.elementTypeId = elementTypeId;
this.sourceId = sourceId;
this.routerKind = routerKind;
this.kind = DrawFeedbackEdgeCommand.KIND;

@@ -66,3 +67,3 @@ }

DrawFeedbackEdgeCommand.prototype.execute = function (context) {
drawFeedbackEdge(context, this.action.sourceId, this.action.elementTypeId);
drawFeedbackEdge(context, this.action.sourceId, this.action.elementTypeId, this.action.routerKind);
return context.root;

@@ -77,3 +78,3 @@ };

return DrawFeedbackEdgeCommand;
}(model_2.FeedbackCommand));
}(model_1.FeedbackCommand));
exports.DrawFeedbackEdgeCommand = DrawFeedbackEdgeCommand;

@@ -101,3 +102,3 @@ var RemoveFeedbackEdgeAction = /** @class */ (function () {

return RemoveFeedbackEdgeCommand;
}(model_2.FeedbackCommand));
}(model_1.FeedbackCommand));
exports.RemoveFeedbackEdgeCommand = RemoveFeedbackEdgeCommand;

@@ -159,3 +160,3 @@ var FeedbackEdgeEnd = /** @class */ (function (_super) {

exports.feedbackEdgeEndId = feedbackEdgeEndId;
function drawFeedbackEdge(context, sourceId, elementTypeId) {
function drawFeedbackEdge(context, sourceId, elementTypeId, routerKind) {
var root = context.root;

@@ -172,3 +173,3 @@ var sourceChild = root.index.getById(sourceId);

edgeEnd.id = feedbackEdgeEndId(root);
edgeEnd.position = { x: source.bounds.x, y: source.bounds.y };
edgeEnd.position = viewpoint_util_1.toAbsolutePosition(source);
var feedbackEdgeSchema = {

@@ -179,6 +180,8 @@ type: 'edge',

targetId: edgeEnd.id,
cssClasses: ["feedback-edge"],
routerKind: routerKind,
opacity: 0.3
};
var feedbackEdge = context.modelFactory.createElement(feedbackEdgeSchema);
if (model_1.isRoutable(feedbackEdge)) {
if (smodel_util_1.isRoutable(feedbackEdge)) {
edgeEnd.feedbackEdge = feedbackEdge;

@@ -185,0 +188,0 @@ root.add(edgeEnd);

@@ -77,6 +77,6 @@ "use strict";

var index = context.root.index;
index.all().filter(model_1.isRoutable).forEach(model_1.removeReconnectHandles);
index.all().filter(smodel_util_1.isRoutable).forEach(model_1.removeReconnectHandles);
if (smodel_util_1.isNotUndefined(this.action.elementId)) {
var routableElement = index.getById(this.action.elementId);
if (smodel_util_1.isNotUndefined(routableElement) && model_1.isRoutable(routableElement)) {
if (smodel_util_1.isNotUndefined(routableElement) && smodel_util_1.isRoutable(routableElement)) {
model_1.addReconnectHandles(routableElement);

@@ -105,3 +105,3 @@ }

var index = context.root.index;
index.all().filter(model_1.isRoutable).forEach(model_1.removeReconnectHandles);
index.all().filter(smodel_util_1.isRoutable).forEach(model_1.removeReconnectHandles);
return context.root;

@@ -233,3 +233,3 @@ };

if (event.button === 0) {
var routingHandle = lib_1.findParentByFeature(target, model_1.isRoutingHandle);
var routingHandle = lib_1.findParentByFeature(target, smodel_util_1.isRoutingHandle);
if (routingHandle !== undefined) {

@@ -261,3 +261,3 @@ result.push(new SwitchRoutingModeAction([target.id], []));

.forEach(function (element) {
if (model_1.isRoutingHandle(element)) {
if (smodel_util_1.isRoutingHandle(element)) {
var point = _this.getHandlePosition(element);

@@ -285,3 +285,3 @@ if (point !== undefined) {

var parent_1 = handle.parent;
if (!model_1.isRoutable(parent_1))
if (!smodel_util_1.isRoutable(parent_1))
return undefined;

@@ -334,3 +334,3 @@ var router = this.edgeRouterRegistry.get(parent_1.routerKind);

var feedbackEdge = context.modelFactory.createElement(feedbackEdgeSchema);
if (model_1.isRoutable(feedbackEdge)) {
if (smodel_util_1.isRoutable(feedbackEdge)) {
edgeEnd.feedbackEdge = feedbackEdge;

@@ -337,0 +337,0 @@ root.add(edgeEnd);

@@ -1,19 +0,4 @@

/********************************************************************************
* Copyright (c) 2019 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
********************************************************************************/
import { VNode } from "snabbdom/vnode";
import { IView, Point, RenderingContext, SModelElement } from "sprotty/lib";
import { SResizeHandle } from '../change-bounds/model';
import { SResizeHandle } from "../change-bounds/model";
/**

@@ -20,0 +5,0 @@ * This view is used for the invisible end of the feedback edge.

"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 });
/********************************************************************************

@@ -17,14 +24,7 @@ * Copyright (c) 2019 EclipseSource and others.

********************************************************************************/
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 });
/** @jsx svg */
var inversify_1 = require("inversify");
var snabbdom_jsx_1 = require("snabbdom-jsx");
var snabbdom = require("snabbdom-jsx");
var lib_1 = require("sprotty/lib");
var model_1 = require("../change-bounds/model");
var JSX = { createElement: snabbdom.svg };
/**

@@ -39,3 +39,3 @@ * This view is used for the invisible end of the feedback edge.

var position = model.position || lib_1.ORIGIN_POINT;
return snabbdom_jsx_1.svg("g", { x: position.x, y: position.y });
return JSX.createElement("g", { x: position.x, y: position.y });
};

@@ -54,3 +54,3 @@ FeedbackEdgeEndView = __decorate([

if (position !== undefined) {
var node = snabbdom_jsx_1.svg("circle", { "class-sprotty-resize-handle": true, "class-mouseover": handle.hoverFeedback, cx: position.x, cy: position.y, r: this.getRadius() });
var node = JSX.createElement("circle", { "class-sprotty-resize-handle": true, "class-mouseover": handle.hoverFeedback, cx: position.x, cy: position.y, r: this.getRadius() });
lib_1.setAttr(node, 'data-kind', handle.location);

@@ -60,7 +60,7 @@ return node;

// Fallback: Create an empty group
return snabbdom_jsx_1.svg("g", null);
return JSX.createElement("g", null);
};
SResizeHandleView.prototype.getPosition = function (handle) {
var parent = handle.parent;
if (model_1.isResizeable(parent)) {
if (model_1.isResizable(parent)) {
if (handle.location === model_1.ResizeHandleLocation.TopLeft) {

@@ -67,0 +67,0 @@ return { x: 0, y: 0 };

@@ -1,6 +0,6 @@

import { Action, KeyTool, MouseListener, SModelElement, SModelRoot, Tool } from "sprotty/lib";
import { Action, BoundsAware, Dimension, ElementAndBounds, KeyTool, ModelLayoutOptions, MouseListener, Point, SModelElement, SModelRoot, SParentElement, Tool } from "sprotty/lib";
import { SResizeHandle } from "../change-bounds/model";
import { IMovementRestrictor } from "../change-bounds/movement-restrictor";
import { IMouseTool } from "../mouse-tool/mouse-tool";
import { SelectionListener, SelectionService } from "../select/selection-service";
import { FeedbackMoveMouseListener } from "../tool-feedback/change-bounds-tool-feedback";
import { IFeedbackActionDispatcher } from "../tool-feedback/feedback-action-dispatcher";

@@ -28,15 +28,17 @@ /**

readonly id: string;
protected feedbackMoveMouseListener: FeedbackMoveMouseListener;
protected changeBoundsListener: ChangeBoundsListener;
protected feedbackMoveMouseListener: MouseListener;
protected changeBoundsListener: MouseListener & SelectionListener;
constructor(selectionService: SelectionService, mouseTool: IMouseTool, keyTool: KeyTool, feedbackDispatcher: IFeedbackActionDispatcher, movementRestrictor?: IMovementRestrictor | undefined);
enable(): void;
protected createMoveMouseListener(): MouseListener;
protected createChangeBoundsListener(): MouseListener & SelectionListener;
disable(): void;
dispatchFeedback(actions: Action[]): void;
}
declare class ChangeBoundsListener extends MouseListener implements SelectionListener {
export declare class ChangeBoundsListener extends MouseListener implements SelectionListener {
protected tool: ChangeBoundsTool;
private lastDragPosition;
private positionDelta;
private activeResizeElementId;
private activeResizeHandle;
protected lastDragPosition: Point | undefined;
protected positionDelta: Point;
protected activeResizeElementId: string | undefined;
protected activeResizeHandle: SResizeHandle | undefined;
constructor(tool: ChangeBoundsTool);

@@ -47,12 +49,18 @@ mouseDown(target: SModelElement, event: MouseEvent): Action[];

selectionChanged(root: SModelRoot, selectedElements: string[]): void;
private setActiveResizeElement;
private isActiveResizeElement;
private initPosition;
private updatePosition;
private reset;
private resetPosition;
private hasPositionDelta;
private handleElementResize;
protected setActiveResizeElement(target: SModelElement): boolean;
protected isActiveResizeElement(element: SModelElement | undefined): element is SParentElement & BoundsAware;
protected initPosition(event: MouseEvent): void;
protected updatePosition(target: SModelElement, event: MouseEvent): boolean;
protected reset(): void;
protected resetPosition(): void;
protected hasPositionDelta(): boolean;
protected handleElementResize(): Action[];
protected createChangeBoundsAction(element: SModelElement & BoundsAware): Action[];
protected createElementAndBounds(element: SModelElement & BoundsAware): ElementAndBounds[];
protected createSetBoundsAction(element: SModelElement & BoundsAware, x: number, y: number, width: number, height: number): Action[];
protected isValidBoundChange(element: SModelElement & BoundsAware, newPosition: Point, newSize: Dimension): boolean;
protected minWidth(element: SModelElement & BoundsAware): number;
protected minHeight(element: SModelElement & BoundsAware): number;
protected getLayoutOptions(element: SModelElement): ModelLayoutOptions | undefined;
}
export {};
//# sourceMappingURL=change-bounds-tool.d.ts.map

@@ -87,10 +87,17 @@ "use strict";

// install feedback move mouse listener for client-side move updates
this.feedbackMoveMouseListener = new change_bounds_tool_feedback_1.FeedbackMoveMouseListener(this.movementRestrictor);
this.feedbackMoveMouseListener = this.createMoveMouseListener();
this.mouseTool.register(this.feedbackMoveMouseListener);
// instlal change bounds listener for client-side resize updates and server-side updates
this.changeBoundsListener = new ChangeBoundsListener(this);
// install change bounds listener for client-side resize updates and server-side updates
this.changeBoundsListener = this.createChangeBoundsListener();
this.mouseTool.register(this.changeBoundsListener);
this.selectionService.register(this.changeBoundsListener);
// register feedback
this.feedbackDispatcher.registerFeedback(this, [new change_bounds_tool_feedback_1.ShowChangeBoundsToolResizeFeedbackAction]);
};
ChangeBoundsTool.prototype.createMoveMouseListener = function () {
return new change_bounds_tool_feedback_1.FeedbackMoveMouseListener(this.movementRestrictor);
};
ChangeBoundsTool.prototype.createChangeBoundsListener = function () {
return new ChangeBoundsListener(this);
};
ChangeBoundsTool.prototype.disable = function () {

@@ -161,2 +168,3 @@ this.mouseTool.deregister(this.changeBoundsListener);

ChangeBoundsListener.prototype.mouseUp = function (target, event) {
var _this = this;
_super.prototype.mouseUp.call(this, target, event);

@@ -171,5 +179,5 @@ if (!this.hasPositionDelta()) {

// An action. Resize, not move.
var resizeElement = lib_1.findParentByFeature(this.activeResizeHandle, model_1.isResizeable);
var resizeElement = lib_1.findParentByFeature(this.activeResizeHandle, model_1.isResizable);
if (this.isActiveResizeElement(resizeElement)) {
createChangeBoundsAction(resizeElement).forEach(function (action) { return actions.push(action); });
this.createChangeBoundsAction(resizeElement).forEach(function (action) { return actions.push(action); });
}

@@ -181,3 +189,3 @@ }

smodel_util_1.forEachElement(target, smodel_util_1.isNonRoutableSelectedBoundsAware, function (element) {
return createElementAndBounds(element).forEach(function (bounds) { return newBounds_1.push(bounds); });
return _this.createElementAndBounds(element).forEach(function (bounds) { return newBounds_1.push(bounds); });
});

@@ -264,19 +272,19 @@ if (newBounds_1.length > 0) {

var actions = [];
var resizeElement = lib_1.findParentByFeature(this.activeResizeHandle, model_1.isResizeable);
var resizeElement = lib_1.findParentByFeature(this.activeResizeHandle, model_1.isResizable);
if (this.isActiveResizeElement(resizeElement)) {
switch (this.activeResizeHandle.location) {
case model_1.ResizeHandleLocation.TopLeft:
createSetBoundsAction(resizeElement, resizeElement.bounds.x + this.positionDelta.x, resizeElement.bounds.y + this.positionDelta.y, resizeElement.bounds.width - this.positionDelta.x, resizeElement.bounds.height - this.positionDelta.y)
this.createSetBoundsAction(resizeElement, resizeElement.bounds.x + this.positionDelta.x, resizeElement.bounds.y + this.positionDelta.y, resizeElement.bounds.width - this.positionDelta.x, resizeElement.bounds.height - this.positionDelta.y)
.forEach(function (action) { return actions.push(action); });
break;
case model_1.ResizeHandleLocation.TopRight:
createSetBoundsAction(resizeElement, resizeElement.bounds.x, resizeElement.bounds.y + this.positionDelta.y, resizeElement.bounds.width + this.positionDelta.x, resizeElement.bounds.height - this.positionDelta.y)
this.createSetBoundsAction(resizeElement, resizeElement.bounds.x, resizeElement.bounds.y + this.positionDelta.y, resizeElement.bounds.width + this.positionDelta.x, resizeElement.bounds.height - this.positionDelta.y)
.forEach(function (action) { return actions.push(action); });
break;
case model_1.ResizeHandleLocation.BottomLeft:
createSetBoundsAction(resizeElement, resizeElement.bounds.x + this.positionDelta.x, resizeElement.bounds.y, resizeElement.bounds.width - this.positionDelta.x, resizeElement.bounds.height + this.positionDelta.y)
this.createSetBoundsAction(resizeElement, resizeElement.bounds.x + this.positionDelta.x, resizeElement.bounds.y, resizeElement.bounds.width - this.positionDelta.x, resizeElement.bounds.height + this.positionDelta.y)
.forEach(function (action) { return actions.push(action); });
break;
case model_1.ResizeHandleLocation.BottomRight:
createSetBoundsAction(resizeElement, resizeElement.bounds.x, resizeElement.bounds.y, resizeElement.bounds.width + this.positionDelta.x, resizeElement.bounds.height + this.positionDelta.y)
this.createSetBoundsAction(resizeElement, resizeElement.bounds.x, resizeElement.bounds.y, resizeElement.bounds.width + this.positionDelta.x, resizeElement.bounds.height + this.positionDelta.y)
.forEach(function (action) { return actions.push(action); });

@@ -288,35 +296,49 @@ break;

};
ChangeBoundsListener.prototype.createChangeBoundsAction = function (element) {
if (this.isValidBoundChange(element, element.bounds, element.bounds)) {
return [new operation_actions_1.ChangeBoundsOperationAction([smodel_util_1.toElementAndBounds(element)])];
}
return [];
};
ChangeBoundsListener.prototype.createElementAndBounds = function (element) {
if (this.isValidBoundChange(element, element.bounds, element.bounds)) {
return [smodel_util_1.toElementAndBounds(element)];
}
return [];
};
ChangeBoundsListener.prototype.createSetBoundsAction = function (element, x, y, width, height) {
var newPosition = { x: x, y: y };
var newSize = { width: width, height: height };
if (this.isValidBoundChange(element, newPosition, newSize)) {
return [new lib_1.SetBoundsAction([{ elementId: element.id, newPosition: newPosition, newSize: newSize }])];
}
return [];
};
ChangeBoundsListener.prototype.isValidBoundChange = function (element, newPosition, newSize) {
return newSize.width >= this.minWidth(element) && newSize.height >= this.minHeight(element);
};
ChangeBoundsListener.prototype.minWidth = function (element) {
var layoutOptions = this.getLayoutOptions(element);
if (layoutOptions !== undefined && typeof layoutOptions.minWidth === 'number') {
return layoutOptions.minWidth;
}
return 1;
};
ChangeBoundsListener.prototype.minHeight = function (element) {
var layoutOptions = this.getLayoutOptions(element);
if (layoutOptions !== undefined && typeof layoutOptions.minHeight === 'number') {
return layoutOptions.minHeight;
}
return 1;
};
ChangeBoundsListener.prototype.getLayoutOptions = function (element) {
var layoutOptions = element.layoutOptions;
if (layoutOptions !== undefined) {
return layoutOptions;
}
return undefined;
};
return ChangeBoundsListener;
}(lib_1.MouseListener));
function createChangeBoundsAction(element) {
if (isValidBoundChange(element, element.bounds, element.bounds)) {
return [new operation_actions_1.ChangeBoundsOperationAction([smodel_util_1.toElementAndBounds(element)])];
}
return [];
}
function createElementAndBounds(element) {
if (isValidBoundChange(element, element.bounds, element.bounds)) {
return [smodel_util_1.toElementAndBounds(element)];
}
return [];
}
function createSetBoundsAction(element, x, y, width, height) {
var newPosition = { x: x, y: y };
var newSize = { width: width, height: height };
if (isValidBoundChange(element, newPosition, newSize)) {
return [new lib_1.SetBoundsAction([{ elementId: element.id, newPosition: newPosition, newSize: newSize }])];
}
return [];
}
function isValidBoundChange(element, newPosition, newSize) {
return newSize.width >= minWidth(element) && newSize.height >= minHeight(element);
}
function minWidth(element) {
// currently there are no element-specific constraints
return 1;
}
function minHeight(element) {
// currently there are no element-specific constraints
return 1;
}
exports.ChangeBoundsListener = ChangeBoundsListener;
//# sourceMappingURL=change-bounds-tool.js.map

@@ -1,4 +0,5 @@

import { Action, AnchorComputerRegistry, SModelElement, Tool } from "sprotty/lib";
import { IEditConfigProvider } from "../../base/edit-config/edit-config";
import { Action, AnchorComputerRegistry, SEdge, SModelElement, Tool } from "sprotty/lib";
import { TypeAware } from "../../base/tool-manager/tool-manager-action-handler";
import { Containable } from "../hints/model";
import { ITypeHintProvider } from "../hints/type-hints";
import { IMouseTool } from "../mouse-tool/mouse-tool";

@@ -24,5 +25,5 @@ import { FeedbackEdgeEndMovingMouseListener } from "../tool-feedback/creation-tool-feedback";

protected tool: NodeCreationTool;
private container?;
protected container?: SModelElement & Containable;
constructor(elementTypeId: string, tool: NodeCreationTool);
private creationAllowed;
protected creationAllowed(elementTypeId: string): boolean | undefined;
nonDraggingMouseUp(target: SModelElement, event: MouseEvent): Action[];

@@ -38,7 +39,7 @@ mouseOver(target: SModelElement, event: MouseEvent): Action[];

protected anchorRegistry: AnchorComputerRegistry;
readonly editConfigProvider: IEditConfigProvider;
readonly typeHintProvider: ITypeHintProvider;
elementTypeId: string;
protected creationToolMouseListener: EdgeCreationToolMouseListener;
protected feedbackEndMovingMouseListener: FeedbackEdgeEndMovingMouseListener;
constructor(mouseTool: IMouseTool, feedbackDispatcher: IFeedbackActionDispatcher, anchorRegistry: AnchorComputerRegistry, editConfigProvider: IEditConfigProvider);
constructor(mouseTool: IMouseTool, feedbackDispatcher: IFeedbackActionDispatcher, anchorRegistry: AnchorComputerRegistry, typeHintProvider: ITypeHintProvider);
readonly id: string;

@@ -52,16 +53,16 @@ enable(): void;

protected tool: EdgeCreationTool;
private source?;
private target?;
private currentTarget?;
private allowedTarget;
private edgeEditConfig?;
protected source?: string;
protected target?: string;
protected currentTarget?: SModelElement;
protected allowedTarget: boolean;
protected proxyEdge: SEdge;
constructor(elementTypeId: string, tool: EdgeCreationTool);
private reinitialize;
protected reinitialize(): void;
nonDraggingMouseUp(element: SModelElement, event: MouseEvent): Action[];
private isSourceSelected;
private isTargetSelected;
protected isSourceSelected(): boolean;
protected isTargetSelected(): boolean;
mouseOver(target: SModelElement, event: MouseEvent): Action[];
private isAllowedSource;
private isAllowedTarget;
protected isAllowedSource(element: SModelElement | undefined): boolean;
protected isAllowedTarget(element: SModelElement | undefined): boolean;
}
//# sourceMappingURL=creation-tool.d.ts.map

@@ -45,5 +45,5 @@ "use strict";

var lib_1 = require("sprotty/lib");
var edit_config_1 = require("../../base/edit-config/edit-config");
var types_1 = require("../../types");
var viewpoint_util_1 = require("../../utils/viewpoint-util");
var model_1 = require("../hints/model");
var operation_actions_1 = require("../operation/operation-actions");

@@ -101,8 +101,8 @@ var set_operations_1 = require("../operation/set-operations");

}
NodeCreationToolMouseListener.prototype.creationAllowed = function (target) {
return this.container || target instanceof lib_1.SModelRoot;
NodeCreationToolMouseListener.prototype.creationAllowed = function (elementTypeId) {
return this.container && this.container.isContainableElement(elementTypeId);
};
NodeCreationToolMouseListener.prototype.nonDraggingMouseUp = function (target, event) {
var result = [];
if (this.creationAllowed(target)) {
if (this.creationAllowed(this.elementTypeId)) {
var containerId = this.container ? this.container.id : undefined;

@@ -118,7 +118,6 @@ var location_1 = viewpoint_util_1.getAbsolutePosition(target, event);

NodeCreationToolMouseListener.prototype.mouseOver = function (target, event) {
var _this = this;
var currentContainer = lib_1.findParent(target, function (e) { return edit_config_1.containmentAllowed(e, _this.elementTypeId); });
var currentContainer = lib_1.findParentByFeature(target, model_1.isContainable);
if (!this.container || currentContainer !== this.container) {
this.container = currentContainer;
var feedback = this.creationAllowed(target)
var feedback = this.creationAllowed(this.elementTypeId)
? new cursor_feedback_1.ApplyCursorCSSFeedbackAction(cursor_feedback_1.CursorCSS.NODE_CREATION) :

@@ -141,7 +140,7 @@ new cursor_feedback_1.ApplyCursorCSSFeedbackAction(cursor_feedback_1.CursorCSS.OPERATION_NOT_ALLOWED);

var EdgeCreationTool = /** @class */ (function () {
function EdgeCreationTool(mouseTool, feedbackDispatcher, anchorRegistry, editConfigProvider) {
function EdgeCreationTool(mouseTool, feedbackDispatcher, anchorRegistry, typeHintProvider) {
this.mouseTool = mouseTool;
this.feedbackDispatcher = feedbackDispatcher;
this.anchorRegistry = anchorRegistry;
this.editConfigProvider = editConfigProvider;
this.typeHintProvider = typeHintProvider;
this.elementTypeId = "unknown";

@@ -176,3 +175,3 @@ }

__param(2, inversify_1.inject(lib_1.AnchorComputerRegistry)),
__param(3, inversify_1.inject(types_1.GLSP_TYPES.IEditConfigProvider)),
__param(3, inversify_1.inject(types_1.GLSP_TYPES.ITypeHintProvider)),
__metadata("design:paramtypes", [Object, Object, lib_1.AnchorComputerRegistry, Object])

@@ -190,6 +189,4 @@ ], EdgeCreationTool);

_this.allowedTarget = false;
var config = tool.editConfigProvider.getEditConfig(_this.elementTypeId);
if (config && config.configType === edit_config_1.edgeEditConfig) {
_this.edgeEditConfig = config;
}
_this.proxyEdge = new lib_1.SEdge();
_this.proxyEdge.type = elementTypeId;
return _this;

@@ -261,6 +258,6 @@ }

EdgeCreationToolMouseListener.prototype.isAllowedSource = function (element) {
return element !== undefined && this.edgeEditConfig ? this.edgeEditConfig.isAllowedSource(element) : false;
return element !== undefined && lib_1.isConnectable(element) && element.canConnect(this.proxyEdge, "source");
};
EdgeCreationToolMouseListener.prototype.isAllowedTarget = function (element) {
return element !== undefined && this.edgeEditConfig ? this.edgeEditConfig.isAllowedTarget(element) : false;
return element !== undefined && lib_1.isConnectable(element) && element.canConnect(this.proxyEdge, "target");
};

@@ -267,0 +264,0 @@ EdgeCreationToolMouseListener = __decorate([

@@ -82,3 +82,3 @@ "use strict";

if (keyboard_1.matchesKeystroke(event, 'Delete')) {
var deleteElementIds = Array.from(element.root.index.all().filter(function (e) { return lib_1.isSelectable(e) && e.selected; })
var deleteElementIds = Array.from(element.root.index.all().filter(function (e) { return lib_1.isDeletable(e) && lib_1.isSelectable(e) && e.selected; })
.filter(function (e) { return e.id !== e.root.id; }).map(function (e) { return e.id; }));

@@ -131,3 +131,3 @@ return [new operation_actions_1.DeleteElementOperationAction(deleteElementIds)];

DeleteToolMouseListener.prototype.mouseUp = function (target, event) {
if (target instanceof lib_1.SModelRoot) {
if (!lib_1.isDeletable(target)) {
return [];

@@ -134,0 +134,0 @@ }

@@ -33,3 +33,4 @@ /********************************************************************************

draggingMouseUp(element: SModelElement, event: MouseEvent): Action[];
readonly isDragging: boolean;
}
//# sourceMappingURL=drag-aware-mouse-listener.d.ts.map

@@ -72,2 +72,9 @@ "use strict";

};
Object.defineProperty(DragAwareMouseListener.prototype, "isDragging", {
get: function () {
return this.isMouseDrag;
},
enumerable: true,
configurable: true
});
return DragAwareMouseListener;

@@ -74,0 +81,0 @@ }(lib_1.MouseListener));

@@ -1,3 +0,4 @@

import { Action, AnchorComputerRegistry, EdgeRouterRegistry, MouseListener, SModelElement, SModelRoot, Tool } from "sprotty/lib";
import { Action, AnchorComputerRegistry, Connectable, EdgeRouterRegistry, MouseListener, SModelElement, SModelRoot, SRoutableElement, SRoutingHandle, Tool } from "sprotty/lib";
import { IMouseTool } from "../mouse-tool/mouse-tool";
import { SReconnectHandle } from "../reconnect/model";
import { SelectionListener, SelectionService } from "../select/selection-service";

@@ -25,19 +26,19 @@ import { FeedbackEdgeRouteMovingMouseListener, FeedbackEdgeSourceMovingMouseListener, FeedbackEdgeTargetMovingMouseListener } from "../tool-feedback/edge-edit-tool-feedback";

protected tool: EdgeEditTool;
private isMouseDown;
private edge?;
private routingHandle?;
private newConnectable?;
private reconnectMode?;
protected isMouseDown: boolean;
protected edge?: SRoutableElement;
protected routingHandle?: SRoutingHandle;
protected newConnectable?: SModelElement & Connectable;
protected reconnectMode?: 'NEW_SOURCE' | 'NEW_TARGET';
constructor(tool: EdgeEditTool);
private isValidEdge;
private setEdgeSelected;
private isEdgeSelected;
private setReconnectHandleSelected;
private isReconnecting;
private isReconnectingNewSource;
private setRoutingHandleSelected;
private requiresReconnect;
private setNewConnectable;
private isReadyToReconnect;
private isReadyToReroute;
protected isValidEdge(edge?: SRoutableElement): edge is SRoutableElement;
protected setEdgeSelected(edge: SRoutableElement): void;
protected isEdgeSelected(): boolean;
protected setReconnectHandleSelected(edge: SRoutableElement, reconnectHandle: SReconnectHandle): void;
protected isReconnecting(): boolean;
protected isReconnectingNewSource(): boolean;
protected setRoutingHandleSelected(edge: SRoutableElement, routingHandle: SRoutingHandle): void;
protected requiresReconnect(sourceId: string, targetId: string): boolean;
protected setNewConnectable(connectable?: SModelElement & Connectable): void;
protected isReadyToReconnect(): boolean | undefined;
protected isReadyToReroute(): boolean;
mouseDown(target: SModelElement, event: MouseEvent): Action[];

@@ -49,6 +50,6 @@ mouseMove(target: SModelElement, event: MouseEvent): Action[];

reset(): void;
private resetData;
private resetFeedback;
protected resetData(): void;
protected resetFeedback(): void;
}
export {};
//# sourceMappingURL=edge-edit-tool.d.ts.map

@@ -76,3 +76,2 @@ "use strict";

var lib_1 = require("sprotty/lib");
var edit_config_1 = require("../../base/edit-config/edit-config");
var types_1 = require("../../types");

@@ -151,3 +150,10 @@ var smodel_util_1 = require("../../utils/smodel-util");

// note: order is important here as we want the reconnect handles to cover the routing handles
this.tool.dispatchFeedback([new edge_edit_tool_feedback_1.SwitchRoutingModeAction([this.edge.id], []), new edge_edit_tool_feedback_1.ShowEdgeReconnectHandlesFeedbackAction(this.edge.id)]);
var feedbackActions = [];
if (lib_1.canEditRouting(edge)) {
feedbackActions.push(new edge_edit_tool_feedback_1.SwitchRoutingModeAction([this.edge.id], []));
}
if (model_1.isReconnectable(edge)) {
feedbackActions.push(new edge_edit_tool_feedback_1.ShowEdgeReconnectHandlesFeedbackAction(this.edge.id));
}
this.tool.dispatchFeedback(feedbackActions);
};

@@ -201,4 +207,4 @@ ReconnectEdgeListener.prototype.isEdgeSelected = function () {

var reconnectHandle = lib_1.findParentByFeature(target, model_1.isReconnectHandle);
var routingHandle = !reconnectHandle ? lib_1.findParentByFeature(target, model_1.isRoutingHandle) : undefined;
var edge = lib_1.findParentByFeature(target, model_1.isRoutable);
var routingHandle = !reconnectHandle ? lib_1.findParentByFeature(target, smodel_util_1.isRoutingHandle) : undefined;
var edge = lib_1.findParentByFeature(target, smodel_util_1.isRoutable);
if (this.isEdgeSelected() && edge && reconnectHandle) {

@@ -246,3 +252,3 @@ // PHASE 2 Reconnect: Select reconnect handle on selected edge

var latestEdge = target.index.getById(this.edge.id);
if (latestEdge && model_1.isRoutable(latestEdge)) {
if (latestEdge && smodel_util_1.isRoutable(latestEdge)) {
result.push(new action_definitions_1.RerouteConnectionOperationAction(latestEdge.id, latestEdge.routingPoints));

@@ -259,5 +265,5 @@ this.routingHandle = undefined;

this.setNewConnectable(currentTarget);
if (currentTarget && edit_config_1.isConfigurableEdge(this.edge)) {
if ((this.reconnectMode === 'NEW_SOURCE' && this.edge.isAllowedSource(currentTarget.type)) ||
(this.reconnectMode === 'NEW_TARGET' && this.edge.isAllowedTarget(currentTarget.type))) {
if (currentTarget) {
if ((this.reconnectMode === 'NEW_SOURCE' && currentTarget.canConnect(this.edge, "source")) ||
(this.reconnectMode === 'NEW_TARGET' && currentTarget.canConnect(this.edge, "target"))) {
this.tool.dispatchFeedback([new cursor_feedback_1.ApplyCursorCSSFeedbackAction(cursor_feedback_1.CursorCSS.EDGE_RECONNECT)]);

@@ -289,3 +295,3 @@ return [];

if (element) {
var edge = lib_1.findParentByFeature(element, model_1.isRoutable);
var edge = lib_1.findParentByFeature(element, smodel_util_1.isRoutable);
if (this.isValidEdge(edge)) {

@@ -292,0 +298,0 @@ // PHASE 1: Select edge

@@ -18,2 +18,3 @@ /********************************************************************************

import glspCommandPaletteModule from "./features/command-palette/di.config";
import glspContextMenuModule from "./features/context-menu/di.config";
import glspEditLabelValidationModule from "./features/edit-label-validation/di.config";

@@ -31,24 +32,35 @@ import executeModule from "./features/execute/di.config";

export * from 'sprotty/lib';
export * from './base/edit-config/edit-config';
export * from './model-source/websocket-diagram-server';
export * from './base/model/update-model-command';
export * from './base/tool-manager/tool-manager-action-handler';
export * from './base/command-stack';
export * from './features/change-bounds/model';
export * from './features/change-bounds/movement-restrictor';
export * from './features/command-palette/action-definitions';
export * from './features/command-palette/action-provider';
export * from './features/context-actions/action-definitions';
export * from './features/command-palette/server-command-palette-provider';
export * from './features/context-menu/mouse-listener';
export * from './features/context-menu/context-menu-service';
export * from './features/context-menu/menu-providers';
export * from './features/edit-label-validation/edit-label-validator';
export * from './features/execute/execute-command';
export * from './features/execute/model';
export * from './features/hints/action-definition';
export * from './features/hints/type-hints-action-initializer';
export * from './features/mouse-tool/di.config';
export * from './features/hints/request-type-hints-action';
export * from './features/hints/type-hints';
export * from './features/hints/model';
export * from './features/layout/layout-commands';
export * from './features/mouse-tool/mouse-tool';
export * from './features/operation/operation-actions';
export * from './features/operation/set-operations';
export * from './features/request-response/action-definitions';
export * from './features/request-response/support';
export * from './features/rank/model';
export * from './features/reconnect/action-definitions';
export * from './features/reconnect/model';
export * from './features/request-response/glsp-action-dispatcher';
export * from './features/save/model';
export * from './features/save/save';
export * from './features/select/di.config';
export * from './features/tool-feedback/change-bounds-tool-feedback';
export * from './features/tool-feedback/creation-tool-feedback';
export * from './features/tool-feedback/cursor-feedback';
export * from './features/tool-feedback/edge-edit-tool-feedback';
export * from './features/tool-feedback/feedback-action-dispatcher';
export * from './features/tool-feedback/model';
export * from './features/tool-feedback/model';
export * from './features/tool-palette/tool-palette';

@@ -59,5 +71,6 @@ export * from './features/tools/change-bounds-tool';

export * from './features/tools/delete-tool';
export * from './features/tools/drag-aware-mouse-listener';
export * from './features/tools/edge-edit-tool';
export * from './features/undo-redo/model';
export * from './features/validation/validate';
export * from './features/layout/layout-commands';
export * from './lib/model';

@@ -69,5 +82,6 @@ export * from './types';

export * from './utils/viewpoint-util';
export * from './model-source/websocket-diagram-server';
export * from "./model-source/glsp-server-status";
export { validationModule, saveModule, executeModule, paletteModule, toolFeedbackModule, defaultGLSPModule, modelHintsModule, glspCommandPaletteModule, requestResponseModule, //
glspSelectModule, glspMouseToolModule, layoutCommandsModule, glspEditLabelValidationModule };
glspContextMenuModule, glspSelectModule, glspMouseToolModule, layoutCommandsModule, glspEditLabelValidationModule };
//# sourceMappingURL=index.d.ts.map

@@ -25,47 +25,60 @@ "use strict";

exports.glspCommandPaletteModule = di_config_2.default;
var di_config_3 = require("./features/edit-label-validation/di.config");
exports.glspEditLabelValidationModule = di_config_3.default;
var di_config_4 = require("./features/execute/di.config");
exports.executeModule = di_config_4.default;
var di_config_5 = require("./features/hints/di.config");
exports.modelHintsModule = di_config_5.default;
var di_config_6 = require("./features/layout/di.config");
exports.layoutCommandsModule = di_config_6.default;
var di_config_7 = require("./features/mouse-tool/di.config");
exports.glspMouseToolModule = di_config_7.default;
var di_config_8 = require("./features/request-response/di.config");
exports.requestResponseModule = di_config_8.default;
var di_config_9 = require("./features/save/di.config");
exports.saveModule = di_config_9.default;
var di_config_10 = require("./features/select/di.config");
exports.glspSelectModule = di_config_10.default;
var di_config_11 = require("./features/tool-feedback/di.config");
exports.toolFeedbackModule = di_config_11.default;
var di_config_12 = require("./features/tool-palette/di.config");
exports.paletteModule = di_config_12.default;
var di_config_13 = require("./features/validation/di.config");
exports.validationModule = di_config_13.default;
var di_config_3 = require("./features/context-menu/di.config");
exports.glspContextMenuModule = di_config_3.default;
var di_config_4 = require("./features/edit-label-validation/di.config");
exports.glspEditLabelValidationModule = di_config_4.default;
var di_config_5 = require("./features/execute/di.config");
exports.executeModule = di_config_5.default;
var di_config_6 = require("./features/hints/di.config");
exports.modelHintsModule = di_config_6.default;
var di_config_7 = require("./features/layout/di.config");
exports.layoutCommandsModule = di_config_7.default;
var di_config_8 = require("./features/mouse-tool/di.config");
exports.glspMouseToolModule = di_config_8.default;
var di_config_9 = require("./features/request-response/di.config");
exports.requestResponseModule = di_config_9.default;
var di_config_10 = require("./features/save/di.config");
exports.saveModule = di_config_10.default;
var di_config_11 = require("./features/select/di.config");
exports.glspSelectModule = di_config_11.default;
var di_config_12 = require("./features/tool-feedback/di.config");
exports.toolFeedbackModule = di_config_12.default;
var di_config_13 = require("./features/tool-palette/di.config");
exports.paletteModule = di_config_13.default;
var di_config_14 = require("./features/validation/di.config");
exports.validationModule = di_config_14.default;
__export(require("sprotty/lib"));
__export(require("./base/edit-config/edit-config"));
__export(require("./model-source/websocket-diagram-server"));
__export(require("./base/model/update-model-command"));
__export(require("./base/tool-manager/tool-manager-action-handler"));
__export(require("./base/command-stack"));
__export(require("./features/change-bounds/model"));
__export(require("./features/change-bounds/movement-restrictor"));
__export(require("./features/command-palette/action-definitions"));
__export(require("./features/command-palette/action-provider"));
__export(require("./features/context-actions/action-definitions"));
__export(require("./features/command-palette/server-command-palette-provider"));
__export(require("./features/context-menu/mouse-listener"));
__export(require("./features/context-menu/context-menu-service"));
__export(require("./features/context-menu/menu-providers"));
__export(require("./features/edit-label-validation/edit-label-validator"));
__export(require("./features/execute/execute-command"));
__export(require("./features/execute/model"));
__export(require("./features/hints/action-definition"));
__export(require("./features/hints/type-hints-action-initializer"));
__export(require("./features/mouse-tool/di.config"));
__export(require("./features/hints/request-type-hints-action"));
__export(require("./features/hints/type-hints"));
__export(require("./features/hints/model"));
__export(require("./features/layout/layout-commands"));
__export(require("./features/mouse-tool/mouse-tool"));
__export(require("./features/operation/operation-actions"));
__export(require("./features/operation/set-operations"));
__export(require("./features/request-response/action-definitions"));
__export(require("./features/request-response/support"));
__export(require("./features/rank/model"));
__export(require("./features/reconnect/action-definitions"));
__export(require("./features/reconnect/model"));
__export(require("./features/request-response/glsp-action-dispatcher"));
__export(require("./features/save/model"));
__export(require("./features/save/save"));
__export(require("./features/select/di.config"));
__export(require("./features/tool-feedback/change-bounds-tool-feedback"));
__export(require("./features/tool-feedback/creation-tool-feedback"));
__export(require("./features/tool-feedback/cursor-feedback"));
__export(require("./features/tool-feedback/edge-edit-tool-feedback"));
__export(require("./features/tool-feedback/feedback-action-dispatcher"));
__export(require("./features/tool-feedback/model"));
__export(require("./features/tool-feedback/model"));
__export(require("./features/tool-palette/tool-palette"));

@@ -76,5 +89,6 @@ __export(require("./features/tools/change-bounds-tool"));

__export(require("./features/tools/delete-tool"));
__export(require("./features/tools/drag-aware-mouse-listener"));
__export(require("./features/tools/edge-edit-tool"));
__export(require("./features/undo-redo/model"));
__export(require("./features/validation/validate"));
__export(require("./features/layout/layout-commands"));
__export(require("./lib/model"));

@@ -86,3 +100,4 @@ __export(require("./types"));

__export(require("./utils/viewpoint-util"));
__export(require("./model-source/websocket-diagram-server"));
__export(require("./model-source/glsp-server-status"));
//# sourceMappingURL=index.js.map

@@ -16,8 +16,10 @@ /********************************************************************************

********************************************************************************/
import { SGraph } from "sprotty/lib";
import { SGraph, SModelElement, SModelElementSchema } from "sprotty/lib";
import { Containable } from "../features/hints/model";
import { Saveable } from "../features/save/model";
export declare class GLSPGraph extends SGraph implements Saveable {
export declare class GLSPGraph extends SGraph implements Saveable, Containable {
static readonly DEFAULT_FEATURES: symbol[];
dirty: boolean;
hasFeature(feature: symbol): boolean;
isContainableElement(input: string | SModelElement | SModelElementSchema): boolean;
}
//# sourceMappingURL=model.d.ts.map

@@ -32,11 +32,15 @@ "use strict";

var lib_1 = require("sprotty/lib");
var model_1 = require("../features/save/model");
var model_1 = require("../features/hints/model");
var model_2 = require("../features/save/model");
var GLSPGraph = /** @class */ (function (_super) {
__extends(GLSPGraph, _super);
function GLSPGraph() {
return _super !== null && _super.apply(this, arguments) || this;
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.dirty = false;
return _this;
}
GLSPGraph.prototype.hasFeature = function (feature) {
return feature === model_1.saveFeature || _super.prototype.hasFeature.call(this, feature);
GLSPGraph.prototype.isContainableElement = function (input) {
return true;
};
GLSPGraph.DEFAULT_FEATURES = [lib_1.viewportFeature, lib_1.exportFeature, model_2.saveFeature, model_1.containerFeature];
return GLSPGraph;

@@ -43,0 +47,0 @@ }(lib_1.SGraph));

@@ -41,10 +41,10 @@ "use strict";

var vscode_ws_jsonrpc_1 = require("vscode-ws-jsonrpc");
var action_definitions_1 = require("../features/command-palette/action-definitions");
var action_definitions_1 = require("../features/context-actions/action-definitions");
var execute_command_1 = require("../features/execute/execute-command");
var action_definition_1 = require("../features/hints/action-definition");
var request_type_hints_action_1 = require("../features/hints/request-type-hints-action");
var set_operations_1 = require("../features/operation/set-operations");
var action_definitions_2 = require("../features/request-response/action-definitions");
var save_1 = require("../features/save/save");
var model_1 = require("../features/undo-redo/model");
var validate_1 = require("../features/validation/validate");
var edit_label_validator_1 = require("../features/edit-label-validation/edit-label-validator");
var GLSPWebsocketDiagramServer = /** @class */ (function (_super) {

@@ -107,3 +107,3 @@ __extends(GLSPWebsocketDiagramServer, _super);

registry.register(execute_command_1.ExecuteServerCommandAction.KIND, diagramServer);
registry.register(action_definition_1.RequestTypeHintsAction.KIND, diagramServer);
registry.register(request_type_hints_action_1.RequestTypeHintsAction.KIND, diagramServer);
registry.register(sprotty_1.ComputedBoundsAction.KIND, diagramServer);

@@ -118,4 +118,4 @@ registry.register(sprotty_1.RequestBoundsCommand.KIND, diagramServer);

registry.register(sprotty_1.ExportSvgAction.KIND, diagramServer);
registry.register(action_definitions_1.RequestCommandPaletteActions.KIND, diagramServer);
registry.register(action_definitions_2.IdentifiableRequestAction.KIND, diagramServer);
registry.register(action_definitions_1.RequestContextActions.KIND, diagramServer);
registry.register(edit_label_validator_1.ValidateLabelEditAction.KIND, diagramServer);
registry.register(validate_1.RequestMarkersAction.KIND, diagramServer);

@@ -122,0 +122,0 @@ registry.register(sprotty_1.LayoutAction.KIND, diagramServer);

@@ -20,5 +20,4 @@ /********************************************************************************

IToolFactory: symbol;
IEditConfigProvider: symbol;
ITypeHintProvider: symbol;
IMovementRestrictor: symbol;
RequestResponseSupport: symbol;
SelectionService: symbol;

@@ -28,3 +27,7 @@ SelectionListener: symbol;

MouseTool: symbol;
IContextMenuService: symbol;
IContextMenuServiceProvider: symbol;
IContextMenuProviderRegistry: symbol;
IContextMenuProvider: symbol;
};
//# sourceMappingURL=types.d.ts.map

@@ -22,10 +22,13 @@ "use strict";

IToolFactory: Symbol.for("Factory<Tool>"),
IEditConfigProvider: Symbol.for("IEditConfigProvider"),
ITypeHintProvider: Symbol.for("ITypeHintProvider"),
IMovementRestrictor: Symbol.for("IMovmementRestrictor"),
RequestResponseSupport: Symbol.for("RequestResponseSupport"),
SelectionService: Symbol.for("SelectionService"),
SelectionListener: Symbol.for("SelectionListener"),
SModelRootListener: Symbol.for("SModelRootListener"),
MouseTool: Symbol.for("MouseTool")
MouseTool: Symbol.for("MouseTool"),
IContextMenuService: Symbol.for("IContextMenuService"),
IContextMenuServiceProvider: Symbol.for("IContextMenuServiceProvider"),
IContextMenuProviderRegistry: Symbol.for("IContextMenuProviderRegistry"),
IContextMenuProvider: Symbol.for("IContextMenuProvider")
};
//# sourceMappingURL=types.js.map

@@ -16,5 +16,4 @@ /********************************************************************************

********************************************************************************/
export declare function contains<T>(array: T[], value: T): boolean;
export declare function remove<T>(array: T[], value: T): boolean;
export declare function distinctAdd<T>(array: T[], value: T): boolean;
//# sourceMappingURL=array-utils.d.ts.map

@@ -18,8 +18,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
function contains(array, value) {
if (value === undefined)
return false;
return array.indexOf(value) >= 0;
}
exports.contains = contains;
function remove(array, value) {

@@ -35,3 +29,3 @@ var index = array.indexOf(value);

function distinctAdd(array, value) {
if (!contains(array, value)) {
if (!array.includes(value)) {
array.push(value);

@@ -38,0 +32,0 @@ return true;

@@ -16,4 +16,3 @@ /********************************************************************************

********************************************************************************/
import { BoundsAware, Selectable, SModelElement, SParentElement } from "sprotty/lib";
import { NodeEditConfig } from "../base/edit-config/edit-config";
import { BoundsAware, Selectable, SModelElement, SRoutableElement, SRoutingHandle } from "sprotty/lib";
export declare function getIndex(element: SModelElement): import("sprotty").SModelIndex<SModelElement>;

@@ -28,4 +27,5 @@ export declare function forEachElement<T>(element: SModelElement, predicate: (element: SModelElement) => element is SModelElement & T, runnable: (element: SModelElement & T) => void): void;

export declare function removeCssClasses(root: SModelElement, cssClasses: string[]): void;
export declare function isContainmentAllowed(element: SModelElement, containableElementTypeId: string): element is SParentElement & NodeEditConfig;
export declare function isNonRoutableSelectedBoundsAware(element: SModelElement): element is SelectableBoundsAware;
export declare function isRoutable<T extends SModelElement>(element: T): element is T & SRoutableElement;
export declare function isRoutingHandle(element: SModelElement | undefined): element is SRoutingHandle;
export declare type SelectableBoundsAware = SModelElement & BoundsAware & Selectable;

@@ -32,0 +32,0 @@ export declare function toElementAndBounds(element: SModelElement & BoundsAware): {

@@ -30,4 +30,2 @@ "use strict";

var lib_1 = require("sprotty/lib");
var edit_config_1 = require("../base/edit-config/edit-config");
var model_1 = require("../features/reconnect/model");
function getIndex(element) {

@@ -114,10 +112,14 @@ return element.root.index;

exports.removeCssClasses = removeCssClasses;
function isContainmentAllowed(element, containableElementTypeId) {
return edit_config_1.isConfigurableNode(element) && element.isContainableElement(containableElementTypeId);
}
exports.isContainmentAllowed = isContainmentAllowed;
function isNonRoutableSelectedBoundsAware(element) {
return lib_1.isBoundsAware(element) && isSelected(element) && !model_1.isRoutable(element);
return lib_1.isBoundsAware(element) && isSelected(element) && !isRoutable(element);
}
exports.isNonRoutableSelectedBoundsAware = isNonRoutableSelectedBoundsAware;
function isRoutable(element) {
return element instanceof lib_1.SRoutableElement && element.routingPoints !== undefined;
}
exports.isRoutable = isRoutable;
function isRoutingHandle(element) {
return element !== undefined && element instanceof lib_1.SRoutingHandle;
}
exports.isRoutingHandle = isRoutingHandle;
function toElementAndBounds(element) {

@@ -124,0 +126,0 @@ return {

@@ -16,4 +16,3 @@ /********************************************************************************

********************************************************************************/
import { Point } from "sprotty/lib";
import { SModelElement } from "sprotty/lib";
import { Bounds, BoundsAware, Dimension, Point, SModelElement } from "sprotty/lib";
/**

@@ -33,2 +32,23 @@ * Return the position corresponding to this mouse event (Browser coordinates)

export declare function getAbsolutePosition(target: SModelElement, mouseEvent: MouseEvent): Point;
/**
* Translates the bounds of the diagram element (local coordinates) into the diagram coordinates system
* (i.e. relative to the Diagram's 0;0 point)
*
* @param target A bounds-aware element from the diagram
*/
export declare function toAbsoluteBounds(element: SModelElement & BoundsAware): Bounds;
/**
* Translates the position of the diagram element (local coordinates) into the diagram coordinates system
* (i.e. relative to the Diagram's 0;0 point)
*
* @param target A bounds-aware element from the diagram
*/
export declare function toAbsolutePosition(target: SModelElement & BoundsAware): Point;
/**
* Translates the size of the diagram element (local coordinates) into the diagram coordinates system
* (i.e. relative to the Diagram's 0;0 point)
*
* @param target A bounds-aware element from the diagram
*/
export declare function toAbsoluteSize(target: SModelElement & BoundsAware): Dimension;
//# sourceMappingURL=viewpoint-util.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/********************************************************************************
* Copyright (c) 2019 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
********************************************************************************/
var lib_1 = require("sprotty/lib");
var lib_2 = require("sprotty/lib");
/**

@@ -23,3 +37,3 @@ * Return the position corresponding to this mouse event (Browser coordinates)

yPos -= canvasBounds.y;
var viewport = lib_1.findParentByFeature(target, lib_2.isViewport);
var viewport = lib_1.findParentByFeature(target, lib_1.isViewport);
var zoom = viewport ? viewport.zoom : 1;

@@ -40,2 +54,37 @@ if (viewport) {

exports.getAbsolutePosition = getAbsolutePosition;
/**
* Translates the bounds of the diagram element (local coordinates) into the diagram coordinates system
* (i.e. relative to the Diagram's 0;0 point)
*
* @param target A bounds-aware element from the diagram
*/
function toAbsoluteBounds(element) {
var location = lib_1.isAlignable(element) ? element.alignment : lib_1.ORIGIN_POINT;
var x = location.x;
var y = location.y;
var width = element.bounds.width;
var height = element.bounds.height;
return lib_1.translateBounds({ x: x, y: y, width: width, height: height }, element, element.root);
}
exports.toAbsoluteBounds = toAbsoluteBounds;
/**
* Translates the position of the diagram element (local coordinates) into the diagram coordinates system
* (i.e. relative to the Diagram's 0;0 point)
*
* @param target A bounds-aware element from the diagram
*/
function toAbsolutePosition(target) {
return toAbsoluteBounds(target);
}
exports.toAbsolutePosition = toAbsolutePosition;
/**
* Translates the size of the diagram element (local coordinates) into the diagram coordinates system
* (i.e. relative to the Diagram's 0;0 point)
*
* @param target A bounds-aware element from the diagram
*/
function toAbsoluteSize(target) {
return toAbsoluteBounds(target);
}
exports.toAbsoluteSize = toAbsoluteSize;
//# sourceMappingURL=viewpoint-util.js.map
{
"name": "@eclipse-glsp/client",
"version": "0.8.0-next.13534ee",
"version": "0.8.0-next.1416c36",
"description": "A sprotty-based client for GLSP",

@@ -36,8 +36,18 @@ "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",

"devDependencies": {
"@types/chai": "4.1.3",
"@types/mocha": "^5.2.7",
"@types/node": "10.14.18",
"@types/uuid": "3.4.5",
"chai": "^4.2.0",
"jenkins-mocha": "^8.0.0",
"mocha": "^6.2.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^2.6.1",
"ts-node": "^8.3.0",
"tslint": "^5.5.0",
"typescript": "3.6.4"
},
"resolutions": {
"**/sprotty": "0.8.0-next.1d772ad"
},
"scripts": {

@@ -49,2 +59,3 @@ "prepare": "yarn run clean && yarn run build",

"watch": "tsc -w",
"test": "jenkins-mocha --opts ./configs/mocha.opts \"./src/**/*.spec.?(ts|tsx)\"",
"publish:latest": "yarn publish --tag latest",

@@ -51,0 +62,0 @@ "publish:next": "yarn publish --new-version \"$(semver $npm_package_version -i minor)-next.$(git rev-parse --short HEAD)\" --tag next"

@@ -1,3 +0,9 @@

# Eclipse GLSP - Client
# Eclipse GLSP - Client [![build-status](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fci.eclipse.org%2Fglsp%2Fjob%2Feclipse-glsp%2Fjob%2Fglsp-client%2Fjob%2Fmaster%2F)](https://ci.eclipse.org/glsp/job/eclipse-glsp/job/glsp-client/job/master)
This package contains a client for the [Graphical Language Server Protocol (GLSP)](https://github.com/eclipse-glsp/glsp) based on [Eclipse Sprotty](https://github.com/eclipse/sprotty).
A web-based diagram client framework for the [Graphical Language Server Protocol (GLSP)](https://github.com/eclipse-glsp/glsp) based on [Eclipse Sprotty](https://github.com/eclipse/sprotty).
This project is built with `yarn` and is available from npm via [@eclipse-glsp/client](https://www.npmjs.com/package/@eclipse-glsp/client).
For more information on building and running the web-based GLSP diagram client, see the [GLSP umbrella project](https://github.com/eclipse-glsp/glsp) and please visit the [Eclipse GLSP Website](https://www.eclipse.org/glsp).
![alt](https://www.eclipse.org/glsp/images/diagramanimated.gif)

@@ -46,4 +46,2 @@ /********************************************************************************

}
handledActionKinds = [SetModelCommand.KIND];
}

@@ -50,0 +48,0 @@

@@ -27,8 +27,14 @@ /********************************************************************************

SModelElement,
SNode,
SParentElement
} from "sprotty/lib";
import { isConfigurableNode, NodeEditConfig } from "../../base/edit-config/edit-config";
export const resizeFeature = Symbol("resizeFeature");
export interface Resizable extends BoundsAware, Selectable {
}
export function isResizable(element: SModelElement): element is SParentElement & Resizable {
return isBoundsAware(element) && isSelectable(element) && element instanceof SParentElement && element.hasFeature(resizeFeature);
}
export enum ResizeHandleLocation {

@@ -41,6 +47,2 @@ TopLeft = "top-left",

export function isResizeable(element: SModelElement): element is SNode & SParentElement & BoundsAware & Selectable & NodeEditConfig {
return isConfigurableNode(element) && element.resizable && isBoundsAware(element) && isSelectable(element) && element instanceof SParentElement;
}
export function isBoundsAwareMoveable(element: SModelElement): element is SModelElement & Locateable & BoundsAware {

@@ -47,0 +49,0 @@ return isMoveable(element) && isBoundsAware(element);

@@ -21,7 +21,5 @@ /********************************************************************************

import { NavigationCommandPaletteActionProvider, ServerCommandPaletteActionProvider } from "./action-provider";
import { ServerCommandPaletteActionProvider } from "./server-command-palette-provider";
const glspCommandPaletteModule = new ContainerModule((bind, unbind, isBound, rebind) => {
bind(TYPES.ICommandPaletteActionProvider).to(NavigationCommandPaletteActionProvider);
bind(ServerCommandPaletteActionProvider).toSelf().inSingletonScope();
const glspCommandPaletteModule = new ContainerModule((bind) => {
bind(TYPES.ICommandPaletteActionProvider).to(ServerCommandPaletteActionProvider);

@@ -28,0 +26,0 @@ });

@@ -21,21 +21,29 @@ /********************************************************************************

EditLabelValidationResult,
generateRequestId,
IEditLabelValidationDecorator,
IEditLabelValidator,
RequestAction,
ResponseAction,
Severity,
SModelElement
SModelElement,
TYPES
} from "sprotty";
import { GLSP_TYPES } from "../../types";
import { RequestResponseSupport } from "../request-response/support";
import { GLSPActionDispatcher } from "../request-response/glsp-action-dispatcher";
export class ValidateLabelEditAction implements Action {
export class ValidateLabelEditAction implements RequestAction<SetLabelEditValidationResultAction> {
static readonly KIND = "validateLabelEdit";
kind = ValidateLabelEditAction.KIND;
constructor(public readonly value: string, public readonly labelId: string) { }
constructor(
public readonly value: string,
public readonly labelId: string,
public readonly requestId: string = generateRequestId()) { }
}
export class SetLabelEditValidationResultAction implements Action {
export class SetLabelEditValidationResultAction implements ResponseAction {
static readonly KIND = "setLabelEditValidationResult";
kind = SetLabelEditValidationResultAction.KIND;
constructor(public readonly result: EditLabelValidationResult) { }
constructor(
public readonly result: EditLabelValidationResult,
public readonly responseId: string = '') { }
}

@@ -51,7 +59,7 @@

@inject(GLSP_TYPES.RequestResponseSupport) protected requestResponseSupport: RequestResponseSupport;
@inject(TYPES.IActionDispatcher) protected actionDispatcher: GLSPActionDispatcher;
validate(value: string, label: EditableLabel & SModelElement): Promise<EditLabelValidationResult> {
const action = new ValidateLabelEditAction(value, label.id);
return this.requestResponseSupport.dispatchRequest(action, this.getValidationResultFromResponse);
return this.actionDispatcher.requestUntil(action).then(response => this.getValidationResultFromResponse(response));
}

@@ -58,0 +66,0 @@

@@ -20,12 +20,12 @@ /********************************************************************************

import { GLSP_TYPES } from "../../types";
import { SetTypeHintsAction } from "./action-definition";
import { ApplyEditConfigCommand, TypeHintsEditConfigProvider } from "./type-hints-action-initializer";
import { SetTypeHintsAction } from "./request-type-hints-action";
import { ApplyTypeHintsCommand, TypeHintProvider } from "./type-hints";
const modelHintsModule = new ContainerModule((bind, _unbind, isBound) => {
bind(TypeHintsEditConfigProvider).toSelf().inSingletonScope();
configureActionHandler({ bind, isBound }, SetTypeHintsAction.KIND, TypeHintsEditConfigProvider);
bind(GLSP_TYPES.IEditConfigProvider).toService(TypeHintsEditConfigProvider);
configureCommand({ bind, isBound }, ApplyEditConfigCommand);
bind(TypeHintProvider).toSelf().inSingletonScope();
bind(GLSP_TYPES.ITypeHintProvider).toService(TypeHintProvider);
configureActionHandler({ bind, isBound }, SetTypeHintsAction.KIND, TypeHintProvider);
configureCommand({ bind, isBound }, ApplyTypeHintsCommand);
});
export default modelHintsModule;

@@ -22,2 +22,3 @@ /********************************************************************************

SModelElement,
SModelExtension,
SRoutableElement,

@@ -27,8 +28,12 @@ SRoutingHandle

const ROUTING_HANDLE_SOURCE_INDEX: number = -2;
export const reconnectFeature = Symbol("reconnectFeature");
export interface Reconnectable extends SModelExtension {
}
export function isRoutable<T extends SModelElement>(element: T): element is T & SRoutableElement {
return element instanceof SRoutableElement && (element as any).routingPoints !== undefined;
export function isReconnectable(element: SModelElement): element is SRoutableElement & Reconnectable {
return element instanceof SRoutableElement && element.hasFeature(reconnectFeature);
}
const ROUTING_HANDLE_SOURCE_INDEX: number = -2;
export function isReconnectHandle(element: SModelElement | undefined): element is SReconnectHandle {

@@ -38,5 +43,2 @@ return element !== undefined && element instanceof SReconnectHandle;

export function isRoutingHandle(element: SModelElement | undefined): element is SRoutingHandle {
return element !== undefined && element instanceof SRoutingHandle;
}

@@ -43,0 +45,0 @@ export function addReconnectHandles(element: SRoutableElement) {

@@ -19,12 +19,8 @@ /********************************************************************************

import { GLSP_TYPES } from "../../types";
import { RequestResponseSupport } from "./support";
import { GLSPActionDispatcher } from "./glsp-action-dispatcher";
const requestResponseModule = new ContainerModule((bind, unbind, isBound, rebind) => {
bind(RequestResponseSupport).toSelf().inSingletonScope();
bind(GLSP_TYPES.RequestResponseSupport).toService(RequestResponseSupport);
bind(TYPES.IActionHandlerInitializer).toService(RequestResponseSupport);
rebind(TYPES.IActionDispatcher).to(GLSPActionDispatcher).inSingletonScope();
});
export default requestResponseModule;

@@ -37,3 +37,9 @@ /********************************************************************************

import { getAbsolutePosition } from "../../utils/viewpoint-util";
import { addResizeHandles, isBoundsAwareMoveable, isResizeable, removeResizeHandles } from "../change-bounds/model";
import {
addResizeHandles,
isBoundsAwareMoveable,
isResizable,
removeResizeHandles,
SResizeHandle
} from "../change-bounds/model";
import { IMovementRestrictor } from "../change-bounds/movement-restrictor";

@@ -62,7 +68,7 @@ import { FeedbackCommand } from "./model";

const index = context.root.index;
index.all().filter(isResizeable).forEach(removeResizeHandles);
index.all().filter(isResizable).forEach(removeResizeHandles);
if (isNotUndefined(this.action.elementId)) {
const resizeElement = index.getById(this.action.elementId);
if (isNotUndefined(resizeElement) && isResizeable(resizeElement)) {
if (isNotUndefined(resizeElement) && isResizable(resizeElement)) {
addResizeHandles(resizeElement);

@@ -85,3 +91,3 @@ }

const index = context.root.index;
index.all().filter(isResizeable).forEach(removeResizeHandles);
index.all().filter(isResizable).forEach(removeResizeHandles);
return context.root;

@@ -103,3 +109,3 @@ }

mouseDown(target: SModelElement, event: MouseEvent): Action[] {
if (event.button === 0) {
if (event.button === 0 && !(target instanceof SResizeHandle)) {
const moveable = findParentByFeature(target, isMoveable);

@@ -116,4 +122,2 @@ if (moveable !== undefined) {

mouseMove(target: SModelElement, event: MouseEvent): Action[] {

@@ -180,3 +184,2 @@ const result: Action[] = [];

}

@@ -34,2 +34,3 @@ /********************************************************************************

SDanglingAnchor,
SEdgeSchema,
SModelElement,

@@ -41,13 +42,11 @@ SModelRoot,

import { getAbsolutePosition } from "../../utils/viewpoint-util";
import { isRoutable } from "../reconnect/model";
import { isRoutable } from "../../utils/smodel-util";
import { getAbsolutePosition, toAbsolutePosition } from "../../utils/viewpoint-util";
import { FeedbackCommand } from "./model";
export class DrawFeedbackEdgeAction implements Action {
kind = DrawFeedbackEdgeCommand.KIND;
constructor(readonly elementTypeId: string, readonly sourceId: string) { }
constructor(readonly elementTypeId: string, readonly sourceId: string, readonly routerKind?: string) { }
}
@injectable()

@@ -62,3 +61,3 @@ export class DrawFeedbackEdgeCommand extends FeedbackCommand {

execute(context: CommandExecutionContext): CommandReturn {
drawFeedbackEdge(context, this.action.sourceId, this.action.elementTypeId);
drawFeedbackEdge(context, this.action.sourceId, this.action.elementTypeId, this.action.routerKind);
return context.root;

@@ -132,3 +131,3 @@ }

function drawFeedbackEdge(context: CommandExecutionContext, sourceId: string, elementTypeId: string) {
function drawFeedbackEdge(context: CommandExecutionContext, sourceId: string, elementTypeId: string, routerKind?: string) {
const root = context.root;

@@ -147,5 +146,5 @@ const sourceChild = root.index.getById(sourceId);

edgeEnd.id = feedbackEdgeEndId(root);
edgeEnd.position = { x: source.bounds.x, y: source.bounds.y };
edgeEnd.position = toAbsolutePosition(source);
const feedbackEdgeSchema = {
const feedbackEdgeSchema = <SEdgeSchema>{
type: 'edge',

@@ -155,2 +154,4 @@ id: feedbackEdgeId(root),

targetId: edgeEnd.id,
cssClasses: ["feedback-edge"],
routerKind,
opacity: 0.3

@@ -157,0 +158,0 @@ };

@@ -45,5 +45,5 @@ /********************************************************************************

import { isNotUndefined, isSelected } from "../../utils/smodel-util";
import { isNotUndefined, isRoutable, isRoutingHandle, isSelected } from "../../utils/smodel-util";
import { getAbsolutePosition } from "../../utils/viewpoint-util";
import { addReconnectHandles, isRoutable, isRoutingHandle, removeReconnectHandles } from "../reconnect/model";
import { addReconnectHandles, removeReconnectHandles } from "../reconnect/model";
import {

@@ -185,3 +185,2 @@ FeedbackEdgeEnd,

export class FeedbackEdgeRouteMovingMouseListener extends MouseListener {

@@ -188,0 +187,0 @@ hasDragged = false;

@@ -25,2 +25,3 @@ /********************************************************************************

KeyTool,
ModelLayoutOptions,
MouseListener,

@@ -37,3 +38,3 @@ Point,

import { forEachElement, isNonRoutableSelectedBoundsAware, isSelected, toElementAndBounds } from "../../utils/smodel-util";
import { isBoundsAwareMoveable, isResizeable, ResizeHandleLocation, SResizeHandle } from "../change-bounds/model";
import { isBoundsAwareMoveable, isResizable, ResizeHandleLocation, SResizeHandle } from "../change-bounds/model";
import { IMovementRestrictor } from "../change-bounds/movement-restrictor";

@@ -68,4 +69,4 @@ import { IMouseTool } from "../mouse-tool/mouse-tool";

protected feedbackMoveMouseListener: FeedbackMoveMouseListener;
protected changeBoundsListener: ChangeBoundsListener;
protected feedbackMoveMouseListener: MouseListener;
protected changeBoundsListener: MouseListener & SelectionListener;

@@ -80,12 +81,22 @@ constructor(@inject(GLSP_TYPES.SelectionService) protected selectionService: SelectionService,

// install feedback move mouse listener for client-side move updates
this.feedbackMoveMouseListener = new FeedbackMoveMouseListener(this.movementRestrictor);
this.feedbackMoveMouseListener = this.createMoveMouseListener();
this.mouseTool.register(this.feedbackMoveMouseListener);
// instlal change bounds listener for client-side resize updates and server-side updates
this.changeBoundsListener = new ChangeBoundsListener(this);
// install change bounds listener for client-side resize updates and server-side updates
this.changeBoundsListener = this.createChangeBoundsListener();
this.mouseTool.register(this.changeBoundsListener);
this.selectionService.register(this.changeBoundsListener);
// register feedback
this.feedbackDispatcher.registerFeedback(this, [new ShowChangeBoundsToolResizeFeedbackAction]);
}
protected createMoveMouseListener(): MouseListener {
return new FeedbackMoveMouseListener(this.movementRestrictor);
}
protected createChangeBoundsListener(): MouseListener & SelectionListener {
return new ChangeBoundsListener(this);
}
disable() {

@@ -103,10 +114,10 @@ this.mouseTool.deregister(this.changeBoundsListener);

class ChangeBoundsListener extends MouseListener implements SelectionListener {
export class ChangeBoundsListener extends MouseListener implements SelectionListener {
// members for calculating the correct position change
private lastDragPosition: Point | undefined = undefined;
private positionDelta: Point = { x: 0, y: 0 };
protected lastDragPosition: Point | undefined = undefined;
protected positionDelta: Point = { x: 0, y: 0 };
// members for resize mode
private activeResizeElementId: string | undefined = undefined;
private activeResizeHandle: SResizeHandle | undefined = undefined;
protected activeResizeElementId: string | undefined = undefined;
protected activeResizeHandle: SResizeHandle | undefined = undefined;

@@ -156,5 +167,5 @@ constructor(protected tool: ChangeBoundsTool) {

// An action. Resize, not move.
const resizeElement = findParentByFeature(this.activeResizeHandle, isResizeable);
const resizeElement = findParentByFeature(this.activeResizeHandle, isResizable);
if (this.isActiveResizeElement(resizeElement)) {
createChangeBoundsAction(resizeElement).forEach(action => actions.push(action));
this.createChangeBoundsAction(resizeElement).forEach(action => actions.push(action));
}

@@ -165,3 +176,3 @@ } else {

forEachElement(target, isNonRoutableSelectedBoundsAware, element =>
createElementAndBounds(element).forEach(bounds => newBounds.push(bounds)));
this.createElementAndBounds(element).forEach(bounds => newBounds.push(bounds)));
if (newBounds.length > 0) {

@@ -193,3 +204,3 @@ actions.push(new ChangeBoundsOperationAction(newBounds));

private setActiveResizeElement(target: SModelElement): boolean {
protected setActiveResizeElement(target: SModelElement): boolean {
// check if we have a selected, moveable element (multi-selection allowed)

@@ -206,11 +217,11 @@ const moveableElement = findParentByFeature(target, isBoundsAwareMoveable);

private isActiveResizeElement(element: SModelElement | undefined): element is SParentElement & BoundsAware {
protected isActiveResizeElement(element: SModelElement | undefined): element is SParentElement & BoundsAware {
return element !== undefined && element.id === this.activeResizeElementId;
}
private initPosition(event: MouseEvent) {
protected initPosition(event: MouseEvent) {
this.lastDragPosition = { x: event.pageX, y: event.pageY };
}
private updatePosition(target: SModelElement, event: MouseEvent): boolean {
protected updatePosition(target: SModelElement, event: MouseEvent): boolean {
if (this.lastDragPosition) {

@@ -229,3 +240,3 @@ const viewport = findParentByFeature(target, isViewport);

private reset() {
protected reset() {
this.tool.dispatchFeedback([new HideChangeBoundsToolResizeFeedbackAction()]);

@@ -235,3 +246,3 @@ this.resetPosition();

private resetPosition() {
protected resetPosition() {
this.activeResizeHandle = undefined;

@@ -242,7 +253,7 @@ this.lastDragPosition = undefined;

private hasPositionDelta(): boolean {
protected hasPositionDelta(): boolean {
return this.positionDelta.x !== 0 || this.positionDelta.y !== 0;
}
private handleElementResize(): Action[] {
protected handleElementResize(): Action[] {
if (!this.activeResizeHandle) {

@@ -253,7 +264,7 @@ return [];

const actions: Action[] = [];
const resizeElement = findParentByFeature(this.activeResizeHandle, isResizeable);
const resizeElement = findParentByFeature(this.activeResizeHandle, isResizable);
if (this.isActiveResizeElement(resizeElement)) {
switch (this.activeResizeHandle.location) {
case ResizeHandleLocation.TopLeft:
createSetBoundsAction(resizeElement,
this.createSetBoundsAction(resizeElement,
resizeElement.bounds.x + this.positionDelta.x,

@@ -266,3 +277,3 @@ resizeElement.bounds.y + this.positionDelta.y,

case ResizeHandleLocation.TopRight:
createSetBoundsAction(resizeElement,
this.createSetBoundsAction(resizeElement,
resizeElement.bounds.x,

@@ -275,3 +286,3 @@ resizeElement.bounds.y + this.positionDelta.y,

case ResizeHandleLocation.BottomLeft:
createSetBoundsAction(resizeElement,
this.createSetBoundsAction(resizeElement,
resizeElement.bounds.x + this.positionDelta.x,

@@ -284,3 +295,3 @@ resizeElement.bounds.y,

case ResizeHandleLocation.BottomRight:
createSetBoundsAction(resizeElement,
this.createSetBoundsAction(resizeElement,
resizeElement.bounds.x,

@@ -296,43 +307,54 @@ resizeElement.bounds.y,

}
}
function createChangeBoundsAction(element: SModelElement & BoundsAware): Action[] {
if (isValidBoundChange(element, element.bounds, element.bounds)) {
return [new ChangeBoundsOperationAction([toElementAndBounds(element)])];
protected createChangeBoundsAction(element: SModelElement & BoundsAware): Action[] {
if (this.isValidBoundChange(element, element.bounds, element.bounds)) {
return [new ChangeBoundsOperationAction([toElementAndBounds(element)])];
}
return [];
}
return [];
}
function createElementAndBounds(element: SModelElement & BoundsAware): ElementAndBounds[] {
if (isValidBoundChange(element, element.bounds, element.bounds)) {
return [toElementAndBounds(element)];
protected createElementAndBounds(element: SModelElement & BoundsAware): ElementAndBounds[] {
if (this.isValidBoundChange(element, element.bounds, element.bounds)) {
return [toElementAndBounds(element)];
}
return [];
}
return [];
}
function createSetBoundsAction(element: SModelElement & BoundsAware, x: number, y: number, width: number, height: number): Action[] {
const newPosition = { x, y };
const newSize = { width, height };
if (isValidBoundChange(element, newPosition, newSize)) {
return [new SetBoundsAction([{ elementId: element.id, newPosition, newSize }])];
protected createSetBoundsAction(element: SModelElement & BoundsAware, x: number, y: number, width: number, height: number): Action[] {
const newPosition = { x, y };
const newSize = { width, height };
if (this.isValidBoundChange(element, newPosition, newSize)) {
return [new SetBoundsAction([{ elementId: element.id, newPosition, newSize }])];
}
return [];
}
return [];
}
protected isValidBoundChange(element: SModelElement & BoundsAware, newPosition: Point, newSize: Dimension): boolean {
return newSize.width >= this.minWidth(element) && newSize.height >= this.minHeight(element);
}
function isValidBoundChange(element: SModelElement & BoundsAware, newPosition: Point, newSize: Dimension): boolean {
return newSize.width >= minWidth(element) && newSize.height >= minHeight(element);
}
protected minWidth(element: SModelElement & BoundsAware): number {
const layoutOptions = this.getLayoutOptions(element);
if (layoutOptions !== undefined && typeof layoutOptions.minWidth === 'number') {
return layoutOptions.minWidth;
}
return 1;
}
function minWidth(element: SModelElement & BoundsAware): number {
// currently there are no element-specific constraints
return 1;
}
protected minHeight(element: SModelElement & BoundsAware): number {
const layoutOptions = this.getLayoutOptions(element);
if (layoutOptions !== undefined && typeof layoutOptions.minHeight === 'number') {
return layoutOptions.minHeight;
}
return 1;
}
function minHeight(element: SModelElement & BoundsAware): number {
// currently there are no element-specific constraints
return 1;
protected getLayoutOptions(element: SModelElement): ModelLayoutOptions | undefined {
const layoutOptions = (element as any).layoutOptions;
if (layoutOptions !== undefined) {
return layoutOptions as ModelLayoutOptions;
}
return undefined;
}
}

@@ -21,15 +21,15 @@ /********************************************************************************

EnableDefaultToolsAction,
findParent,
findParentByFeature,
isConnectable,
isCtrlOrCmd,
SEdge,
SModelElement,
SModelRoot,
Tool
} from "sprotty/lib";
import { containmentAllowed, EdgeEditConfig, edgeEditConfig, IEditConfigProvider } from "../../base/edit-config/edit-config";
import { TypeAware } from "../../base/tool-manager/tool-manager-action-handler";
import { GLSP_TYPES } from "../../types";
import { getAbsolutePosition } from "../../utils/viewpoint-util";
import { Containable, isContainable } from "../hints/model";
import { ITypeHintProvider } from "../hints/type-hints";
import { IMouseTool } from "../mouse-tool/mouse-tool";

@@ -47,3 +47,2 @@ import { CreateConnectionOperationAction, CreateNodeOperationAction } from "../operation/operation-actions";

export const TOOL_ID_PREFIX = "tool";

@@ -85,3 +84,3 @@

export class NodeCreationToolMouseListener extends DragAwareMouseListener {
private container?: SModelElement;
protected container?: SModelElement & Containable;
constructor(protected elementTypeId: string, protected tool: NodeCreationTool) {

@@ -91,4 +90,4 @@ super();

private creationAllowed(target: SModelElement) {
return this.container || target instanceof SModelRoot;
protected creationAllowed(elementTypeId: string) {
return this.container && this.container.isContainableElement(elementTypeId);
}

@@ -98,3 +97,3 @@

const result: Action[] = [];
if (this.creationAllowed(target)) {
if (this.creationAllowed(this.elementTypeId)) {
const containerId = this.container ? this.container.id : undefined;

@@ -111,6 +110,6 @@ const location = getAbsolutePosition(target, event);

mouseOver(target: SModelElement, event: MouseEvent): Action[] {
const currentContainer = findParent(target, e => containmentAllowed(e, this.elementTypeId));
const currentContainer = findParentByFeature(target, isContainable);
if (!this.container || currentContainer !== this.container) {
this.container = currentContainer;
const feedback = this.creationAllowed(target)
const feedback = this.creationAllowed(this.elementTypeId)
? new ApplyCursorCSSFeedbackAction(CursorCSS.NODE_CREATION) :

@@ -137,3 +136,3 @@ new ApplyCursorCSSFeedbackAction(CursorCSS.OPERATION_NOT_ALLOWED);

@inject(AnchorComputerRegistry) protected anchorRegistry: AnchorComputerRegistry,
@inject(GLSP_TYPES.IEditConfigProvider) public readonly editConfigProvider: IEditConfigProvider) { }
@inject(GLSP_TYPES.ITypeHintProvider) public readonly typeHintProvider: ITypeHintProvider) { }

@@ -166,17 +165,14 @@ get id() {

export class EdgeCreationToolMouseListener extends DragAwareMouseListener {
private source?: string;
private target?: string;
private currentTarget?: SModelElement;
private allowedTarget: boolean = false;
private edgeEditConfig?: EdgeEditConfig;
protected source?: string;
protected target?: string;
protected currentTarget?: SModelElement;
protected allowedTarget: boolean = false;
protected proxyEdge: SEdge;
constructor(protected elementTypeId: string, protected tool: EdgeCreationTool) {
super();
const config = tool.editConfigProvider.getEditConfig(this.elementTypeId);
if (config && config.configType === edgeEditConfig) {
this.edgeEditConfig = config as EdgeEditConfig;
}
this.proxyEdge = new SEdge();
this.proxyEdge.type = elementTypeId;
}
private reinitialize() {
protected reinitialize() {
this.source = undefined;

@@ -216,7 +212,7 @@ this.target = undefined;

private isSourceSelected() {
protected isSourceSelected() {
return this.source !== undefined;
}
private isTargetSelected() {
protected isTargetSelected() {
return this.target !== undefined;

@@ -247,9 +243,10 @@ }

private isAllowedSource(element: SModelElement | undefined): boolean {
return element !== undefined && this.edgeEditConfig ? this.edgeEditConfig.isAllowedSource(element) : false;
protected isAllowedSource(element: SModelElement | undefined): boolean {
return element !== undefined && isConnectable(element) && element.canConnect(this.proxyEdge, "source");
}
private isAllowedTarget(element: SModelElement | undefined): boolean {
return element !== undefined && this.edgeEditConfig ? this.edgeEditConfig.isAllowedTarget(element) : false;
protected isAllowedTarget(element: SModelElement | undefined): boolean {
return element !== undefined && isConnectable(element) && element.canConnect(this.proxyEdge, "target");
}
}

@@ -21,2 +21,3 @@ /********************************************************************************

isCtrlOrCmd,
isDeletable,
isSelectable,

@@ -27,3 +28,2 @@ KeyListener,

SModelElement,
SModelRoot,
Tool

@@ -64,3 +64,3 @@ } from "sprotty/lib";

if (matchesKeystroke(event, 'Delete')) {
const deleteElementIds = Array.from(element.root.index.all().filter(e => isSelectable(e) && e.selected)
const deleteElementIds = Array.from(element.root.index.all().filter(e => isDeletable(e) && isSelectable(e) && e.selected)
.filter(e => e.id !== e.root.id).map(e => e.id));

@@ -96,4 +96,2 @@ return [new DeleteElementOperationAction(deleteElementIds)];

}
}

@@ -104,3 +102,3 @@

mouseUp(target: SModelElement, event: MouseEvent): Action[] {
if (target instanceof SModelRoot) {
if (!isDeletable(target)) {
return [];

@@ -107,0 +105,0 @@ }

@@ -61,2 +61,6 @@ /********************************************************************************

get isDragging() {
return this.isMouseDrag;
}
}

@@ -20,2 +20,3 @@ /********************************************************************************

AnchorComputerRegistry,
canEditRouting,
Connectable,

@@ -33,11 +34,9 @@ EdgeRouterRegistry,

import { isConfigurableEdge } from "../../base/edit-config/edit-config";
import { GLSP_TYPES } from "../../types";
import { isSelected } from "../../utils/smodel-util";
import { isRoutable, isRoutingHandle, isSelected } from "../../utils/smodel-util";
import { IMouseTool } from "../mouse-tool/mouse-tool";
import { ReconnectConnectionOperationAction, RerouteConnectionOperationAction } from "../reconnect/action-definitions";
import {
isReconnectable,
isReconnectHandle,
isRoutable,
isRoutingHandle,
isSourceRoutingHandle,

@@ -107,13 +106,13 @@ isTargetRoutingHandle,

class ReconnectEdgeListener extends MouseListener implements SelectionListener {
private isMouseDown: boolean;
protected isMouseDown: boolean;
// active selection data
private edge?: SRoutableElement;
private routingHandle?: SRoutingHandle;
protected edge?: SRoutableElement;
protected routingHandle?: SRoutingHandle;
// new connectable (source or target) for edge
private newConnectable?: SModelElement & Connectable;
protected newConnectable?: SModelElement & Connectable;
// active reconnect handle data
private reconnectMode?: 'NEW_SOURCE' | 'NEW_TARGET';
protected reconnectMode?: 'NEW_SOURCE' | 'NEW_TARGET';

@@ -124,7 +123,7 @@ constructor(protected tool: EdgeEditTool) {

private isValidEdge(edge?: SRoutableElement): edge is SRoutableElement {
protected isValidEdge(edge?: SRoutableElement): edge is SRoutableElement {
return edge !== undefined && edge.id !== feedbackEdgeId(edge.root) && isSelected(edge);
}
private setEdgeSelected(edge: SRoutableElement) {
protected setEdgeSelected(edge: SRoutableElement) {
if (this.edge && this.edge.id !== edge.id) {

@@ -137,10 +136,17 @@ // reset from a previously selected edge

// note: order is important here as we want the reconnect handles to cover the routing handles
this.tool.dispatchFeedback([new SwitchRoutingModeAction([this.edge.id], []), new ShowEdgeReconnectHandlesFeedbackAction(this.edge.id)]);
const feedbackActions = [];
if (canEditRouting(edge)) {
feedbackActions.push(new SwitchRoutingModeAction([this.edge.id], []));
}
if (isReconnectable(edge)) {
feedbackActions.push(new ShowEdgeReconnectHandlesFeedbackAction(this.edge.id));
}
this.tool.dispatchFeedback(feedbackActions);
}
private isEdgeSelected(): boolean {
protected isEdgeSelected(): boolean {
return this.edge !== undefined && isSelected(this.edge);
}
private setReconnectHandleSelected(edge: SRoutableElement, reconnectHandle: SReconnectHandle) {
protected setReconnectHandleSelected(edge: SRoutableElement, reconnectHandle: SReconnectHandle) {
if (this.edge && this.edge.target && this.edge.source) {

@@ -161,11 +167,11 @@ if (isSourceRoutingHandle(edge, reconnectHandle)) {

private isReconnecting(): boolean {
protected isReconnecting(): boolean {
return this.reconnectMode !== undefined;
}
private isReconnectingNewSource(): boolean {
protected isReconnectingNewSource(): boolean {
return this.reconnectMode === "NEW_SOURCE";
}
private setRoutingHandleSelected(edge: SRoutableElement, routingHandle: SRoutingHandle) {
protected setRoutingHandleSelected(edge: SRoutableElement, routingHandle: SRoutingHandle) {
if (this.edge && this.edge.target && this.edge.source) {

@@ -176,15 +182,15 @@ this.routingHandle = routingHandle;

private requiresReconnect(sourceId: string, targetId: string): boolean {
protected requiresReconnect(sourceId: string, targetId: string): boolean {
return this.edge !== undefined && (this.edge.sourceId !== sourceId || this.edge.targetId !== targetId);
}
private setNewConnectable(connectable?: SModelElement & Connectable) {
protected setNewConnectable(connectable?: SModelElement & Connectable) {
this.newConnectable = connectable;
}
private isReadyToReconnect() {
protected isReadyToReconnect() {
return this.edge && this.isReconnecting() && this.newConnectable !== undefined;
}
private isReadyToReroute() {
protected isReadyToReroute() {
return this.routingHandle !== undefined;

@@ -254,5 +260,5 @@ }

this.setNewConnectable(currentTarget);
if (currentTarget && isConfigurableEdge(this.edge)) {
if ((this.reconnectMode === 'NEW_SOURCE' && this.edge.isAllowedSource(currentTarget.type)) ||
(this.reconnectMode === 'NEW_TARGET' && this.edge.isAllowedTarget(currentTarget.type))) {
if (currentTarget) {
if ((this.reconnectMode === 'NEW_SOURCE' && currentTarget.canConnect(this.edge, "source")) ||
(this.reconnectMode === 'NEW_TARGET' && currentTarget.canConnect(this.edge, "target"))) {

@@ -303,3 +309,3 @@ this.tool.dispatchFeedback([new ApplyCursorCSSFeedbackAction(CursorCSS.EDGE_RECONNECT)]);

private resetData() {
protected resetData() {
this.isMouseDown = false;

@@ -312,3 +318,3 @@ this.edge = undefined;

private resetFeedback() {
protected resetFeedback() {
const result: Action[] = [];

@@ -315,0 +321,0 @@ if (this.edge) {

@@ -18,2 +18,3 @@ /********************************************************************************

import glspCommandPaletteModule from "./features/command-palette/di.config";
import glspContextMenuModule from "./features/context-menu/di.config";
import glspEditLabelValidationModule from "./features/edit-label-validation/di.config";

@@ -32,24 +33,36 @@ import executeModule from "./features/execute/di.config";

export * from 'sprotty/lib';
export * from './base/edit-config/edit-config';
export * from './model-source/websocket-diagram-server';
export * from './base/model/update-model-command';
export * from './base/tool-manager/tool-manager-action-handler';
export * from './base/command-stack';
export * from './features/change-bounds/model';
export * from './features/change-bounds/movement-restrictor';
export * from './features/command-palette/action-definitions';
export * from './features/command-palette/action-provider';
export * from './features/context-actions/action-definitions';
export * from './features/command-palette/server-command-palette-provider';
export * from './features/context-menu/mouse-listener';
export * from './features/context-menu/context-menu-service';
export * from './features/context-menu/menu-providers';
export * from './features/edit-label-validation/edit-label-validator';
export * from './features/execute/execute-command';
export * from './features/execute/model';
export * from './features/hints/action-definition';
export * from './features/hints/type-hints-action-initializer';
export * from './features/mouse-tool/di.config';
export * from './features/hints/request-type-hints-action';
export * from './features/hints/type-hints';
export * from './features/hints/model';
export * from './features/layout/layout-commands';
export * from './features/mouse-tool/mouse-tool';
export * from './features/operation/operation-actions';
export * from './features/operation/set-operations';
export * from './features/request-response/action-definitions';
export * from './features/request-response/support';
export * from './features/rank/model';
export * from './features/reconnect/action-definitions';
export * from './features/reconnect/model';
export * from './features/request-response/glsp-action-dispatcher';
export * from './features/save/model';
export * from './features/save/save';
export * from './features/select/di.config';
export * from './features/tool-feedback/change-bounds-tool-feedback';
export * from './features/tool-feedback/creation-tool-feedback';
export * from './features/tool-feedback/cursor-feedback';
export * from './features/tool-feedback/edge-edit-tool-feedback';
export * from './features/tool-feedback/feedback-action-dispatcher';
export * from './features/tool-feedback/model';
export * from './features/tool-feedback/model';
export * from './features/tool-palette/tool-palette';

@@ -60,5 +73,7 @@ export * from './features/tools/change-bounds-tool';

export * from './features/tools/delete-tool';
export * from './features/tools/drag-aware-mouse-listener';
export * from './features/tools/edge-edit-tool';
export * from './features/undo-redo/model';
export * from './features/validation/validate';
export * from './features/layout/layout-commands';
export * from './lib/model';

@@ -70,9 +85,9 @@ export * from './types';

export * from './utils/viewpoint-util';
export * from './model-source/websocket-diagram-server';
export * from "./model-source/glsp-server-status";
export {
validationModule, saveModule, executeModule, paletteModule, toolFeedbackModule, defaultGLSPModule, modelHintsModule, glspCommandPaletteModule, requestResponseModule, //
glspSelectModule, glspMouseToolModule, layoutCommandsModule, glspEditLabelValidationModule
glspContextMenuModule, glspSelectModule, glspMouseToolModule, layoutCommandsModule, glspEditLabelValidationModule
};

@@ -16,12 +16,13 @@ /********************************************************************************

********************************************************************************/
import { SGraph } from "sprotty/lib";
import { exportFeature, SGraph, SModelElement, SModelElementSchema, viewportFeature } from "sprotty/lib";
import { Containable, containerFeature } from "../features/hints/model";
import { Saveable, saveFeature } from "../features/save/model";
export class GLSPGraph extends SGraph implements Saveable {
dirty: boolean;
hasFeature(feature: symbol) {
return feature === saveFeature || super.hasFeature(feature);
export class GLSPGraph extends SGraph implements Saveable, Containable {
static readonly DEFAULT_FEATURES = [viewportFeature, exportFeature, saveFeature, containerFeature];
dirty: boolean = false;
isContainableElement(input: string | SModelElement | SModelElementSchema): boolean {
return true;
}
}

@@ -26,10 +26,10 @@ /********************************************************************************

import { NotificationType } from "vscode-ws-jsonrpc";
import { RequestCommandPaletteActions } from "../features/command-palette/action-definitions";
import { RequestContextActions } from "../features/context-actions/action-definitions";
import { ExecuteServerCommandAction } from "../features/execute/execute-command";
import { RequestTypeHintsAction } from "../features/hints/action-definition";
import { RequestTypeHintsAction } from "../features/hints/request-type-hints-action";
import { OperationKind, RequestOperationsAction } from "../features/operation/set-operations";
import { IdentifiableRequestAction } from "../features/request-response/action-definitions";
import { SaveModelAction } from "../features/save/save";
import { GlspRedoAction, GlspUndoAction } from "../features/undo-redo/model";
import { RequestMarkersAction } from "../features/validation/validate";
import { ValidateLabelEditAction } from "../features/edit-label-validation/edit-label-validator";

@@ -50,3 +50,2 @@ @injectable()

});
}

@@ -104,4 +103,4 @@

registry.register(ExportSvgAction.KIND, diagramServer);
registry.register(RequestCommandPaletteActions.KIND, diagramServer);
registry.register(IdentifiableRequestAction.KIND, diagramServer);
registry.register(RequestContextActions.KIND, diagramServer);
registry.register(ValidateLabelEditAction.KIND, diagramServer);
registry.register(RequestMarkersAction.KIND, diagramServer);

@@ -108,0 +107,0 @@ registry.register(LayoutAction.KIND, diagramServer);

@@ -20,9 +20,12 @@ /********************************************************************************

IToolFactory: Symbol.for("Factory<Tool>"),
IEditConfigProvider: Symbol.for("IEditConfigProvider"),
ITypeHintProvider: Symbol.for("ITypeHintProvider"),
IMovementRestrictor: Symbol.for("IMovmementRestrictor"),
RequestResponseSupport: Symbol.for("RequestResponseSupport"),
SelectionService: Symbol.for("SelectionService"),
SelectionListener: Symbol.for("SelectionListener"),
SModelRootListener: Symbol.for("SModelRootListener"),
MouseTool: Symbol.for("MouseTool")
MouseTool: Symbol.for("MouseTool"),
IContextMenuService: Symbol.for("IContextMenuService"),
IContextMenuServiceProvider: Symbol.for("IContextMenuServiceProvider"),
IContextMenuProviderRegistry: Symbol.for("IContextMenuProviderRegistry"),
IContextMenuProvider: Symbol.for("IContextMenuProvider")
};

@@ -17,7 +17,2 @@ /********************************************************************************

export function contains<T>(array: T[], value: T): boolean {
if (value === undefined) return false;
return array.indexOf(value) >= 0;
}
export function remove<T>(array: T[], value: T): boolean {

@@ -33,3 +28,3 @@ const index = array.indexOf(value);

export function distinctAdd<T>(array: T[], value: T): boolean {
if (!contains(array, value)) {
if (!array.includes(value)) {
array.push(value);

@@ -36,0 +31,0 @@ return true;

@@ -16,6 +16,12 @@ /********************************************************************************

********************************************************************************/
import { BoundsAware, isBoundsAware, isSelectable, Selectable, SModelElement, SParentElement } from "sprotty/lib";
import {
BoundsAware,
isBoundsAware,
isSelectable,
Selectable,
SModelElement,
SRoutableElement,
SRoutingHandle
} from "sprotty/lib";
import { isConfigurableNode, NodeEditConfig } from "../base/edit-config/edit-config";
import { isRoutable } from "../features/reconnect/model";

@@ -81,7 +87,2 @@ export function getIndex(element: SModelElement) {

export function isContainmentAllowed(element: SModelElement, containableElementTypeId: string)
: element is SParentElement & NodeEditConfig {
return isConfigurableNode(element) && element.isContainableElement(containableElementTypeId);
}
export function isNonRoutableSelectedBoundsAware(element: SModelElement): element is SelectableBoundsAware {

@@ -91,2 +92,10 @@ return isBoundsAware(element) && isSelected(element) && !isRoutable(element);

export function isRoutable<T extends SModelElement>(element: T): element is T & SRoutableElement {
return element instanceof SRoutableElement && (element as any).routingPoints !== undefined;
}
export function isRoutingHandle(element: SModelElement | undefined): element is SRoutingHandle {
return element !== undefined && element instanceof SRoutingHandle;
}
export type SelectableBoundsAware = SModelElement & BoundsAware & Selectable;

@@ -93,0 +102,0 @@

@@ -16,9 +16,16 @@ /********************************************************************************

********************************************************************************/
import { Point } from "sprotty/lib";
import { SModelElement } from "sprotty/lib";
import { Viewport } from "sprotty/lib";
import {
Bounds,
BoundsAware,
Dimension,
findParentByFeature,
isAlignable,
isViewport,
ORIGIN_POINT,
Point,
SModelElement,
translateBounds,
Viewport
} from "sprotty/lib";
import { findParentByFeature } from "sprotty/lib";
import { isViewport } from "sprotty/lib";
/**

@@ -60,1 +67,36 @@ * Return the position corresponding to this mouse event (Browser coordinates)

}
/**
* Translates the bounds of the diagram element (local coordinates) into the diagram coordinates system
* (i.e. relative to the Diagram's 0;0 point)
*
* @param target A bounds-aware element from the diagram
*/
export function toAbsoluteBounds(element: SModelElement & BoundsAware): Bounds {
const location = isAlignable(element) ? element.alignment : ORIGIN_POINT;
const x = location.x;
const y = location.y;
const width = element.bounds.width;
const height = element.bounds.height;
return translateBounds({ x, y, width, height }, element, element.root);
}
/**
* Translates the position of the diagram element (local coordinates) into the diagram coordinates system
* (i.e. relative to the Diagram's 0;0 point)
*
* @param target A bounds-aware element from the diagram
*/
export function toAbsolutePosition(target: SModelElement & BoundsAware): Point {
return toAbsoluteBounds(target);
}
/**
* Translates the size of the diagram element (local coordinates) into the diagram coordinates system
* (i.e. relative to the Diagram's 0;0 point)
*
* @param target A bounds-aware element from the diagram
*/
export function toAbsoluteSize(target: SModelElement & BoundsAware): Dimension {
return toAbsoluteBounds(target);
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc