@glsp/sprotty-client
Advanced tools
Comparing version 0.2.0-next.ea3e4b20 to 0.2.0-next.f38fca9e
@@ -1,2 +0,2 @@ | ||
import { CommandStack, SModelRoot } from "sprotty/lib"; | ||
import { CommandStack, IActionDispatcher, SModelRoot } from "sprotty/lib"; | ||
/** | ||
@@ -24,4 +24,7 @@ * Provides access to the current `SModelRoot` instance. | ||
export declare class GLSPCommandStack extends CommandStack implements IReadonlyModelAccess { | ||
protected actionDispatcher: () => Promise<IActionDispatcher>; | ||
readonly model: Promise<SModelRoot>; | ||
undo(): Promise<SModelRoot>; | ||
redo(): Promise<SModelRoot>; | ||
} | ||
//# sourceMappingURL=command-stack.d.ts.map |
@@ -21,2 +21,5 @@ "use strict"; | ||
}; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -40,2 +43,3 @@ /******************************************************************************** | ||
var lib_1 = require("sprotty/lib"); | ||
var model_1 = require("../features/undo-redo/model"); | ||
var GLSPCommandStack = /** @class */ (function (_super) { | ||
@@ -54,2 +58,14 @@ __extends(GLSPCommandStack, _super); | ||
}); | ||
GLSPCommandStack.prototype.undo = function () { | ||
this.actionDispatcher().then(function (dispatcher) { return dispatcher.dispatch(new model_1.GlspUndoAction()); }); | ||
return this.thenUpdate(); | ||
}; | ||
GLSPCommandStack.prototype.redo = function () { | ||
this.actionDispatcher().then(function (dispatcher) { return dispatcher.dispatch(new model_1.GlspRedoAction()); }); | ||
return this.thenUpdate(); | ||
}; | ||
__decorate([ | ||
inversify_1.inject(lib_1.TYPES.IActionDispatcherProvider), | ||
__metadata("design:type", Function) | ||
], GLSPCommandStack.prototype, "actionDispatcher", void 0); | ||
GLSPCommandStack = __decorate([ | ||
@@ -56,0 +72,0 @@ inversify_1.injectable() |
@@ -22,2 +22,3 @@ "use strict"; | ||
var types_1 = require("../types"); | ||
var command_stack_1 = require("./command-stack"); | ||
var update_model_command_1 = require("./model/update-model-command"); | ||
@@ -33,2 +34,3 @@ var tool_manager_action_handler_1 = require("./tool-manager/tool-manager-action-handler"); | ||
bind(lib_1.TYPES.IActionHandlerInitializer).to(update_model_command_1.SetModelActionHandler); | ||
rebind(lib_1.TYPES.ICommandStack).to(command_stack_1.GLSPCommandStack); | ||
bind(types_1.GLSP_TYPES.ViewerOptions).toConstantValue(viewer_options_1.defaultGLSPViewerOptions()); | ||
@@ -35,0 +37,0 @@ if (isBound(lib_1.TYPES.ViewerOptions)) { |
@@ -16,8 +16,10 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import { Action, LabeledAction } from "sprotty/lib"; | ||
import { Action, LabeledAction, Point } from "sprotty/lib"; | ||
export declare class RequestCommandPaletteActions implements Action { | ||
readonly selectedElementsIDs: string[]; | ||
readonly selectedElementIds: string[]; | ||
readonly text: string; | ||
readonly lastMousePosition?: Point | undefined; | ||
static readonly KIND = "requestCommandPaletteActions"; | ||
kind: string; | ||
constructor(selectedElementsIDs?: string[]); | ||
constructor(selectedElementIds: string[], text: string, lastMousePosition?: Point | undefined); | ||
} | ||
@@ -24,0 +26,0 @@ export declare class SetCommandPaletteActions implements Action { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var RequestCommandPaletteActions = /** @class */ (function () { | ||
function RequestCommandPaletteActions(selectedElementsIDs) { | ||
if (selectedElementsIDs === void 0) { selectedElementsIDs = []; } | ||
this.selectedElementsIDs = selectedElementsIDs; | ||
function RequestCommandPaletteActions(selectedElementIds, text, lastMousePosition) { | ||
if (selectedElementIds === void 0) { selectedElementIds = []; } | ||
this.selectedElementIds = selectedElementIds; | ||
this.text = text; | ||
this.lastMousePosition = lastMousePosition; | ||
this.kind = RequestCommandPaletteActions.KIND; | ||
@@ -8,0 +10,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Action, ICommandPaletteActionProvider, ILogger, LabeledAction, SModelElement } from "sprotty/lib"; | ||
import { Action, ICommandPaletteActionProvider, ILogger, LabeledAction, Point, SModelElement } from "sprotty/lib"; | ||
import { RequestResponseSupport } from "../request-response/support"; | ||
@@ -11,5 +11,5 @@ export declare class NavigationCommandPaletteActionProvider implements ICommandPaletteActionProvider { | ||
constructor(requestResponseSupport: RequestResponseSupport); | ||
getActions(root: Readonly<SModelElement>): Promise<LabeledAction[]>; | ||
getActions(root: Readonly<SModelElement>, text: string, lastMousePosition?: Point): Promise<LabeledAction[]>; | ||
getPaletteActionsFromResponse(action: Action): LabeledAction[]; | ||
} | ||
//# sourceMappingURL=action-provider.d.ts.map |
@@ -44,3 +44,3 @@ "use strict"; | ||
.filter(lib_1.isNameable) | ||
.map(function (nameable) { return new lib_1.LabeledAction("Select " + lib_1.name(nameable), [new lib_1.SelectAction([nameable.id]), new lib_1.CenterAction([nameable.id])]); }))); | ||
.map(function (nameable) { return new lib_1.LabeledAction("Select " + lib_1.name(nameable), [new lib_1.SelectAction([nameable.id]), new lib_1.CenterAction([nameable.id])], 'fa-object-group'); }))); | ||
}; | ||
@@ -59,5 +59,5 @@ NavigationCommandPaletteActionProvider = __decorate([ | ||
} | ||
ServerCommandPaletteActionProvider.prototype.getActions = function (root) { | ||
var selectedElementIDs = Array.from(root.index.all().filter(smodel_util_1.isSelected).map(function (e) { return e.id; })); | ||
var requestAction = new action_definitions_1.RequestCommandPaletteActions(selectedElementIDs); | ||
ServerCommandPaletteActionProvider.prototype.getActions = function (root, text, lastMousePosition) { | ||
var selectedElementIds = Array.from(root.index.all().filter(smodel_util_1.isSelected).map(function (e) { return e.id; })); | ||
var requestAction = new action_definitions_1.RequestCommandPaletteActions(selectedElementIds, text, lastMousePosition); | ||
var responseHandler = this.getPaletteActionsFromResponse; | ||
@@ -64,0 +64,0 @@ var promise = this.requestResponseSupport.dispatchRequest(requestAction, responseHandler); |
@@ -58,4 +58,8 @@ import { Action, AnchorComputerRegistry, SModelElement, Tool } from "sprotty/lib"; | ||
nonDraggingMouseUp(element: SModelElement, event: MouseEvent): Action[]; | ||
private isSourceSelected; | ||
private isTargetSelected; | ||
mouseOver(target: SModelElement, event: MouseEvent): Action[]; | ||
private isAllowedSource; | ||
private isAllowedTarget; | ||
} | ||
//# sourceMappingURL=creation-tool.d.ts.map |
@@ -194,3 +194,5 @@ "use strict"; | ||
this.target = undefined; | ||
this.tool.dispatchFeedback([new cursor_feedback_1.ApplyCursorCSSFeedbackAction(cursor_feedback_1.CursorCSS.OPERATION_NOT_ALLOWED)]); | ||
this.currentTarget = undefined; | ||
this.allowedTarget = false; | ||
this.tool.dispatchFeedback([new creation_tool_feedback_1.RemoveFeedbackEdgeAction()]); | ||
}; | ||
@@ -200,3 +202,3 @@ EdgeCreationToolMouseListener.prototype.nonDraggingMouseUp = function (element, event) { | ||
if (event.button === 0) { | ||
if (this.source === undefined) { | ||
if (!this.isSourceSelected()) { | ||
if (this.currentTarget && this.allowedTarget) { | ||
@@ -212,3 +214,3 @@ this.source = this.currentTarget.id; | ||
} | ||
if (this.source !== undefined && this.target !== undefined) { | ||
if (this.isSourceSelected() && this.isTargetSelected()) { | ||
result.push(new operation_actions_1.CreateConnectionOperationAction(this.elementTypeId, this.source, this.target)); | ||
@@ -228,2 +230,8 @@ if (!lib_1.isCtrlOrCmd(event)) { | ||
}; | ||
EdgeCreationToolMouseListener.prototype.isSourceSelected = function () { | ||
return this.source !== undefined; | ||
}; | ||
EdgeCreationToolMouseListener.prototype.isTargetSelected = function () { | ||
return this.target !== undefined; | ||
}; | ||
EdgeCreationToolMouseListener.prototype.mouseOver = function (target, event) { | ||
@@ -234,5 +242,10 @@ var newCurrentTarget = lib_1.findParentByFeature(target, lib_1.isConnectable); | ||
if (this.currentTarget) { | ||
this.allowedTarget = this.edgeEditConfig ? this.edgeEditConfig.isAllowedTarget(this.currentTarget) : false; | ||
if (!this.isSourceSelected()) { | ||
this.allowedTarget = this.isAllowedSource(newCurrentTarget); | ||
} | ||
else if (!this.isTargetSelected()) { | ||
this.allowedTarget = this.isAllowedTarget(newCurrentTarget); | ||
} | ||
if (this.allowedTarget) { | ||
var action = this.source === undefined ? new cursor_feedback_1.ApplyCursorCSSFeedbackAction(cursor_feedback_1.CursorCSS.EDGE_CREATION_SOURCE) : | ||
var action = !this.isSourceSelected() ? new cursor_feedback_1.ApplyCursorCSSFeedbackAction(cursor_feedback_1.CursorCSS.EDGE_CREATION_SOURCE) : | ||
new cursor_feedback_1.ApplyCursorCSSFeedbackAction(cursor_feedback_1.CursorCSS.EDGE_CREATION_TARGET); | ||
@@ -246,2 +259,8 @@ return [action]; | ||
}; | ||
EdgeCreationToolMouseListener.prototype.isAllowedSource = function (element) { | ||
return element !== undefined && this.edgeEditConfig ? this.edgeEditConfig.isAllowedSource(element) : false; | ||
}; | ||
EdgeCreationToolMouseListener.prototype.isAllowedTarget = function (element) { | ||
return element !== undefined && this.edgeEditConfig ? this.edgeEditConfig.isAllowedTarget(element) : false; | ||
}; | ||
EdgeCreationToolMouseListener = __decorate([ | ||
@@ -248,0 +267,0 @@ inversify_1.injectable(), |
@@ -57,2 +57,3 @@ /******************************************************************************** | ||
export * from './features/tools/delete-tool'; | ||
export * from './features/undo-redo/model'; | ||
export * from './features/validation/validate'; | ||
@@ -66,4 +67,5 @@ export * from './features/layout/layout-commands'; | ||
export * from './utils/viewpoint-util'; | ||
export * from "./model-source/glsp-server-status"; | ||
export { validationModule, saveModule, executeModule, paletteModule, toolFeedbackModule, defaultGLSPModule, modelHintsModule, glspCommandPaletteModule, requestResponseModule, // | ||
glspSelectModule, glspMouseToolModule, layoutCommandsModule, glspEditLabelValidationModule }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -75,2 +75,3 @@ "use strict"; | ||
__export(require("./features/tools/delete-tool")); | ||
__export(require("./features/undo-redo/model")); | ||
__export(require("./features/validation/validate")); | ||
@@ -84,2 +85,3 @@ __export(require("./features/layout/layout-commands")); | ||
__export(require("./utils/viewpoint-util")); | ||
__export(require("./model-source/glsp-server-status")); | ||
//# sourceMappingURL=index.js.map |
@@ -47,2 +47,3 @@ "use strict"; | ||
var save_1 = require("../features/save/save"); | ||
var model_1 = require("../features/undo-redo/model"); | ||
var validate_1 = require("../features/validation/validate"); | ||
@@ -97,2 +98,4 @@ var GLSPWebsocketDiagramServer = /** @class */ (function (_super) { | ||
registry.register(save_1.SaveModelAction.KIND, diagramServer); | ||
registry.register(model_1.GlspUndoAction.KIND, diagramServer); | ||
registry.register(model_1.GlspRedoAction.KIND, diagramServer); | ||
registry.register(set_operations_1.OperationKind.CREATE_CONNECTION, diagramServer); | ||
@@ -99,0 +102,0 @@ registry.register(set_operations_1.OperationKind.RECONNECT_CONNECTION, diagramServer); |
{ | ||
"name": "@glsp/sprotty-client", | ||
"version": "0.2.0-next.ea3e4b20", | ||
"version": "0.2.0-next.f38fca9e", | ||
"description": "A sprotty-based client for GLSP", | ||
@@ -31,3 +31,3 @@ "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)", | ||
"autocompleter": "^4.0.2", | ||
"sprotty": "0.7.0-next.cea0e2b", | ||
"sprotty": "0.7.0-next.797c619", | ||
"vscode-ws-jsonrpc": "^0.0.2-1" | ||
@@ -34,0 +34,0 @@ }, |
@@ -16,5 +16,7 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import { injectable } from "inversify"; | ||
import { CommandStack, SModelRoot } from "sprotty/lib"; | ||
import { inject, injectable } from "inversify"; | ||
import { CommandStack, IActionDispatcher, SModelRoot, TYPES } from "sprotty/lib"; | ||
import { GlspRedoAction, GlspUndoAction } from "../features/undo-redo/model"; | ||
/** | ||
@@ -46,2 +48,4 @@ * Provides access to the current `SModelRoot` instance. | ||
@inject(TYPES.IActionDispatcherProvider) protected actionDispatcher: () => Promise<IActionDispatcher>; | ||
get model(): Promise<SModelRoot> { | ||
@@ -52,3 +56,13 @@ return this.currentPromise.then( | ||
} | ||
undo(): Promise<SModelRoot> { | ||
this.actionDispatcher().then(dispatcher => dispatcher.dispatch(new GlspUndoAction())); | ||
return this.thenUpdate(); | ||
} | ||
redo(): Promise<SModelRoot> { | ||
this.actionDispatcher().then(dispatcher => dispatcher.dispatch(new GlspRedoAction())); | ||
return this.thenUpdate(); | ||
} | ||
} | ||
@@ -22,2 +22,3 @@ /******************************************************************************** | ||
import { GLSP_TYPES } from "../types"; | ||
import { GLSPCommandStack } from "./command-stack"; | ||
import { FeedbackAwareUpdateModelCommand, SetModelActionHandler } from "./model/update-model-command"; | ||
@@ -36,2 +37,3 @@ import { createToolFactory, ToolManagerActionHandler } from "./tool-manager/tool-manager-action-handler"; | ||
rebind(TYPES.ICommandStack).to(GLSPCommandStack); | ||
@@ -38,0 +40,0 @@ bind<GLSPViewerOptions>(GLSP_TYPES.ViewerOptions).toConstantValue(defaultGLSPViewerOptions()); |
@@ -16,3 +16,3 @@ /******************************************************************************** | ||
********************************************************************************/ | ||
import { Action, LabeledAction } from "sprotty/lib"; | ||
import { Action, LabeledAction, Point } from "sprotty/lib"; | ||
@@ -22,3 +22,6 @@ export class RequestCommandPaletteActions implements Action { | ||
kind = RequestCommandPaletteActions.KIND; | ||
constructor(public readonly selectedElementsIDs: string[] = []) { } | ||
constructor( | ||
public readonly selectedElementIds: string[] = [], | ||
public readonly text: string, | ||
public readonly lastMousePosition?: Point) { } | ||
} | ||
@@ -25,0 +28,0 @@ |
@@ -25,5 +25,6 @@ /******************************************************************************** | ||
name, | ||
Point, | ||
SelectAction, | ||
SModelElement, | ||
TYPES, | ||
TYPES | ||
} from "sprotty/lib"; | ||
@@ -40,10 +41,9 @@ import { toArray } from "sprotty/lib/utils/iterable"; | ||
constructor( | ||
constructor(@inject(TYPES.ILogger) protected logger: ILogger) { } | ||
@inject(TYPES.ILogger) protected logger: ILogger) { } | ||
getActions(root: Readonly<SModelElement>): Promise<LabeledAction[]> { | ||
return Promise.resolve(toArray(root.index.all() | ||
.filter(isNameable) | ||
.map(nameable => new LabeledAction(`Select ${name(nameable)}`, [new SelectAction([nameable.id]), new CenterAction([nameable.id])])))); | ||
.map(nameable => new LabeledAction(`Select ${name(nameable)}`, | ||
[new SelectAction([nameable.id]), new CenterAction([nameable.id])], 'fa-object-group')))); | ||
} | ||
@@ -54,8 +54,8 @@ } | ||
export class ServerCommandPaletteActionProvider implements ICommandPaletteActionProvider { | ||
constructor(@inject(GLSP_TYPES.RequestResponseSupport) protected requestResponseSupport: RequestResponseSupport) { | ||
} | ||
getActions(root: Readonly<SModelElement>): Promise<LabeledAction[]> { | ||
const selectedElementIDs = Array.from(root.index.all().filter(isSelected).map(e => e.id)); | ||
const requestAction = new RequestCommandPaletteActions(selectedElementIDs); | ||
constructor(@inject(GLSP_TYPES.RequestResponseSupport) protected requestResponseSupport: RequestResponseSupport) { } | ||
getActions(root: Readonly<SModelElement>, text: string, lastMousePosition?: Point): Promise<LabeledAction[]> { | ||
const selectedElementIds = Array.from(root.index.all().filter(isSelected).map(e => e.id)); | ||
const requestAction = new RequestCommandPaletteActions(selectedElementIds, text, lastMousePosition); | ||
const responseHandler = this.getPaletteActionsFromResponse; | ||
@@ -62,0 +62,0 @@ const promise = this.requestResponseSupport.dispatchRequest(requestAction, responseHandler); |
@@ -102,4 +102,2 @@ /******************************************************************************** | ||
} | ||
return result; | ||
@@ -179,3 +177,5 @@ } | ||
this.target = undefined; | ||
this.tool.dispatchFeedback([new ApplyCursorCSSFeedbackAction(CursorCSS.OPERATION_NOT_ALLOWED)]); | ||
this.currentTarget = undefined; | ||
this.allowedTarget = false; | ||
this.tool.dispatchFeedback([new RemoveFeedbackEdgeAction()]); | ||
} | ||
@@ -186,3 +186,3 @@ | ||
if (event.button === 0) { | ||
if (this.source === undefined) { | ||
if (!this.isSourceSelected()) { | ||
if (this.currentTarget && this.allowedTarget) { | ||
@@ -197,3 +197,3 @@ this.source = this.currentTarget.id; | ||
} | ||
if (this.source !== undefined && this.target !== undefined) { | ||
if (this.isSourceSelected() && this.isTargetSelected()) { | ||
result.push(new CreateConnectionOperationAction(this.elementTypeId, this.source, this.target)); | ||
@@ -212,2 +212,11 @@ if (!isCtrlOrCmd(event)) { | ||
private isSourceSelected() { | ||
return this.source !== undefined; | ||
} | ||
private isTargetSelected() { | ||
return this.target !== undefined; | ||
} | ||
mouseOver(target: SModelElement, event: MouseEvent): Action[] { | ||
@@ -218,5 +227,9 @@ const newCurrentTarget = findParentByFeature(target, isConnectable); | ||
if (this.currentTarget) { | ||
this.allowedTarget = this.edgeEditConfig ? this.edgeEditConfig.isAllowedTarget(this.currentTarget) : false; | ||
if (!this.isSourceSelected()) { | ||
this.allowedTarget = this.isAllowedSource(newCurrentTarget); | ||
} else if (!this.isTargetSelected()) { | ||
this.allowedTarget = this.isAllowedTarget(newCurrentTarget); | ||
} | ||
if (this.allowedTarget) { | ||
const action = this.source === undefined ? new ApplyCursorCSSFeedbackAction(CursorCSS.EDGE_CREATION_SOURCE) : | ||
const action = !this.isSourceSelected() ? new ApplyCursorCSSFeedbackAction(CursorCSS.EDGE_CREATION_SOURCE) : | ||
new ApplyCursorCSSFeedbackAction(CursorCSS.EDGE_CREATION_TARGET); | ||
@@ -230,2 +243,10 @@ return [action]; | ||
} | ||
private isAllowedSource(element: SModelElement | undefined): boolean { | ||
return element !== undefined && this.edgeEditConfig ? this.edgeEditConfig.isAllowedSource(element) : false; | ||
} | ||
private isAllowedTarget(element: SModelElement | undefined): boolean { | ||
return element !== undefined && this.edgeEditConfig ? this.edgeEditConfig.isAllowedTarget(element) : false; | ||
} | ||
} |
@@ -58,2 +58,3 @@ /******************************************************************************** | ||
export * from './features/tools/delete-tool'; | ||
export * from './features/undo-redo/model'; | ||
export * from './features/validation/validate'; | ||
@@ -67,2 +68,4 @@ export * from './features/layout/layout-commands'; | ||
export * from './utils/viewpoint-util'; | ||
export * from "./model-source/glsp-server-status"; | ||
export { | ||
@@ -69,0 +72,0 @@ validationModule, saveModule, executeModule, paletteModule, toolFeedbackModule, defaultGLSPModule, modelHintsModule, glspCommandPaletteModule, requestResponseModule, // |
@@ -32,2 +32,3 @@ /******************************************************************************** | ||
import { SaveModelAction } from "../features/save/save"; | ||
import { GlspRedoAction, GlspUndoAction } from "../features/undo-redo/model"; | ||
import { RequestMarkersAction } from "../features/validation/validate"; | ||
@@ -64,2 +65,3 @@ | ||
} | ||
handle(action: Action): void | ICommand | Action { | ||
@@ -83,2 +85,4 @@ if (action instanceof RequestModelAction && action.options !== undefined) | ||
registry.register(SaveModelAction.KIND, diagramServer); | ||
registry.register(GlspUndoAction.KIND, diagramServer); | ||
registry.register(GlspRedoAction.KIND, diagramServer); | ||
registry.register(OperationKind.CREATE_CONNECTION, diagramServer); | ||
@@ -85,0 +89,0 @@ registry.register(OperationKind.RECONNECT_CONNECTION, diagramServer); |
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
891967
341
14080
10
60
+ Addedsprotty@0.7.0-next.797c619(transitive)
- Removedsprotty@0.7.0-next.cea0e2b(transitive)
Updatedsprotty@0.7.0-next.797c619