@glsp/sprotty-client
Advanced tools
Comparing version 0.2.0-next.23ce4e1f to 0.2.0-next.2402c9fc
@@ -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); |
@@ -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()]); | ||
}; | ||
@@ -197,0 +199,0 @@ EdgeCreationToolMouseListener.prototype.nonDraggingMouseUp = function (element, event) { |
@@ -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 |
@@ -1,4 +0,8 @@ | ||
import { Action, ActionHandlerRegistry, ComputedBoundsAction, DiagramServer, ICommand, WebSocketDiagramServer } from "sprotty"; | ||
export declare class GLSPWebsocketDiagramServer extends WebSocketDiagramServer { | ||
import { Action, ActionHandlerRegistry, ActionMessage, ComputedBoundsAction, DiagramServer, ICommand } from "sprotty"; | ||
import * as rpc from "vscode-ws-jsonrpc"; | ||
export declare class GLSPWebsocketDiagramServer extends DiagramServer { | ||
protected _sourceUri: string; | ||
protected connection: rpc.MessageConnection; | ||
listen(webSocket: WebSocket): void; | ||
protected sendMessage(message: ActionMessage): void; | ||
initialize(registry: ActionHandlerRegistry): void; | ||
@@ -5,0 +9,0 @@ handle(action: Action): void | ICommand | Action; |
@@ -39,2 +39,4 @@ "use strict"; | ||
var sprotty_1 = require("sprotty"); | ||
var rpc = require("vscode-ws-jsonrpc"); | ||
var vscode_ws_jsonrpc_1 = require("vscode-ws-jsonrpc"); | ||
var action_definitions_1 = require("../features/command-palette/action-definitions"); | ||
@@ -46,2 +48,3 @@ var execute_command_1 = require("../features/execute/execute-command"); | ||
var save_1 = require("../features/save/save"); | ||
var model_1 = require("../features/undo-redo/model"); | ||
var validate_1 = require("../features/validation/validate"); | ||
@@ -53,2 +56,21 @@ var GLSPWebsocketDiagramServer = /** @class */ (function (_super) { | ||
} | ||
GLSPWebsocketDiagramServer.prototype.listen = function (webSocket) { | ||
var _this = this; | ||
rpc.listen({ | ||
webSocket: webSocket, | ||
onConnection: function (connection) { | ||
connection.listen(); | ||
connection.onNotification(ActionMessageNotification.type, function (message) { return _this.messageReceived(message); }); | ||
_this.connection = connection; | ||
} | ||
}); | ||
}; | ||
GLSPWebsocketDiagramServer.prototype.sendMessage = function (message) { | ||
if (this.connection) { | ||
this.connection.sendNotification(ActionMessageNotification.type, message); | ||
} | ||
else { | ||
throw new Error('WebSocket is not connected'); | ||
} | ||
}; | ||
GLSPWebsocketDiagramServer.prototype.initialize = function (registry) { | ||
@@ -73,3 +95,3 @@ registerDefaultGLSPServerActions(registry, this); | ||
return GLSPWebsocketDiagramServer; | ||
}(sprotty_1.WebSocketDiagramServer)); | ||
}(sprotty_1.DiagramServer)); | ||
exports.GLSPWebsocketDiagramServer = GLSPWebsocketDiagramServer; | ||
@@ -79,2 +101,4 @@ function registerDefaultGLSPServerActions(registry, diagramServer) { | ||
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); | ||
@@ -108,2 +132,6 @@ registry.register(set_operations_1.OperationKind.RECONNECT_CONNECTION, diagramServer); | ||
exports.registerDefaultGLSPServerActions = registerDefaultGLSPServerActions; | ||
var ActionMessageNotification; | ||
(function (ActionMessageNotification) { | ||
ActionMessageNotification.type = new vscode_ws_jsonrpc_1.NotificationType('process'); | ||
})(ActionMessageNotification || (ActionMessageNotification = {})); | ||
//# sourceMappingURL=websocket-diagram-server.js.map |
{ | ||
"name": "@glsp/sprotty-client", | ||
"version": "0.2.0-next.23ce4e1f", | ||
"version": "0.2.0-next.2402c9fc", | ||
"description": "A sprotty-based client for GLSP", | ||
@@ -31,3 +31,4 @@ "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 +35,0 @@ "devDependencies": { |
@@ -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()]); | ||
} | ||
@@ -182,0 +182,0 @@ |
@@ -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, // |
@@ -18,21 +18,10 @@ /******************************************************************************** | ||
import { | ||
Action, | ||
ActionHandlerRegistry, | ||
ApplyLabelEditAction, | ||
CollapseExpandAction, | ||
CollapseExpandAllAction, | ||
ComputedBoundsAction, | ||
DiagramServer, | ||
ExportSvgAction, | ||
ICommand, | ||
LayoutAction, | ||
OpenAction, | ||
RequestBoundsCommand, | ||
RequestModelAction, | ||
RequestPopupModelAction, | ||
ServerStatusAction, | ||
SwitchEditModeCommand, | ||
WebSocketDiagramServer | ||
Action, ActionHandlerRegistry, ActionMessage, | ||
ApplyLabelEditAction, CollapseExpandAction, CollapseExpandAllAction, | ||
ComputedBoundsAction, DiagramServer, ExportSvgAction, ICommand, LayoutAction, | ||
OpenAction, RequestBoundsCommand, RequestModelAction, RequestPopupModelAction, | ||
ServerStatusAction, SwitchEditModeCommand | ||
} from "sprotty"; | ||
import * as rpc from "vscode-ws-jsonrpc"; | ||
import { NotificationType } from "vscode-ws-jsonrpc"; | ||
import { RequestCommandPaletteActions } from "../features/command-palette/action-definitions"; | ||
@@ -44,9 +33,30 @@ import { ExecuteServerCommandAction } from "../features/execute/execute-command"; | ||
import { SaveModelAction } from "../features/save/save"; | ||
import { GlspRedoAction, GlspUndoAction } from "../features/undo-redo/model"; | ||
import { RequestMarkersAction } from "../features/validation/validate"; | ||
@injectable() | ||
export class GLSPWebsocketDiagramServer extends WebSocketDiagramServer { | ||
export class GLSPWebsocketDiagramServer extends DiagramServer { | ||
protected _sourceUri: string; | ||
protected connection: rpc.MessageConnection; | ||
listen(webSocket: WebSocket): void { | ||
rpc.listen({ | ||
webSocket, | ||
onConnection: (connection: rpc.MessageConnection) => { | ||
connection.listen(); | ||
connection.onNotification(ActionMessageNotification.type, (message: ActionMessage) => this.messageReceived(message)); | ||
this.connection = connection; | ||
} | ||
}); | ||
} | ||
protected sendMessage(message: ActionMessage): void { | ||
if (this.connection) { | ||
this.connection.sendNotification(ActionMessageNotification.type, message); | ||
} else { | ||
throw new Error('WebSocket is not connected'); | ||
} | ||
} | ||
initialize(registry: ActionHandlerRegistry): void { | ||
@@ -56,2 +66,3 @@ registerDefaultGLSPServerActions(registry, this); | ||
} | ||
handle(action: Action): void | ICommand | Action { | ||
@@ -75,2 +86,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); | ||
@@ -104,1 +117,6 @@ registry.register(OperationKind.RECONNECT_CONNECTION, diagramServer); | ||
} | ||
namespace ActionMessageNotification { | ||
export const type = new NotificationType<ActionMessage, void>('process'); | ||
} | ||
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 3 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 2 instances in 1 package
889650
341
14043
3
10
60
+ Addedvscode-ws-jsonrpc@^0.0.2-1
+ Addedsprotty@0.7.0-next.797c619(transitive)
+ Addedvscode-jsonrpc@3.6.2(transitive)
+ Addedvscode-ws-jsonrpc@0.0.2-2(transitive)
- Removedsprotty@0.7.0-next.cea0e2b(transitive)
Updatedsprotty@0.7.0-next.797c619