Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { GModelRoot } from '@eclipse-glsp/graph';
import { Action, ComputedBoundsAction, MaybePromise } from '@eclipse-glsp/protocol';
import { Action, ComputedBoundsAction, LayoutOperation, MaybePromise } from '@eclipse-glsp/protocol';
import { inject, injectable } from 'inversify';
import { ActionHandler } from '../../actions/action-handler';
import { applyAlignment, applyElementAndBounds, applyRoute } from '../../utils/layout-util';
Expand All @@ -39,7 +39,10 @@ export class ComputedBoundsActionHandler implements ActionHandler {
const model = this.modelState.root;
if (action.revision === model.revision) {
this.applyBounds(model, action);
return this.submissionHandler.submitModelDirectly();
return this.submissionHandler.submitModelDirectly(
undefined,
LayoutOperation.create([], { canvasBounds: action.canvasBounds, viewport: action.viewport })
);
}

return [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
Action,
DirtyStateChangeReason,
GModelRootSchema,
LayoutOperation,
MarkersReason,
MaybePromise,
RequestBoundsAction,
Expand Down Expand Up @@ -112,9 +113,10 @@ export class ModelSubmissionHandler {
* to the `ActionDispatcher`, or simply returned as the result of an `ActionHandler.execute()` method.
*
* @param reason The optional reason that caused the model update.
* @param layout The optional layout operation that carries the information for auto-layout.
* @returns A list of actions to be processed in order to submit the model.
*/
submitModel(reason?: DirtyStateChangeReason): MaybePromise<Action[]> {
submitModel(reason?: DirtyStateChangeReason, layout?: LayoutOperation): MaybePromise<Action[]> {
this.modelFactory.createModel();

const revision = this.requestModelAction ? 0 : this.modelState.root.revision! + 1;
Expand All @@ -124,7 +126,7 @@ export class ModelSubmissionHandler {
const root = this.serializeGModel();
return [RequestBoundsAction.create(root), SetDirtyStateAction.create(this.commandStack.isDirty, { reason })];
}
return this.submitModelDirectly(reason);
return this.submitModelDirectly(reason, layout);
}

/**
Expand All @@ -139,11 +141,12 @@ export class ModelSubmissionHandler {
* `ActionHandler.execute()` method.
*
* @param reason The optional reason that caused the model update.
* @param layout The optional layout operation that carries the information for auto-layout.
* @returns A list of actions to be processed in order to submit the model.
*/
async submitModelDirectly(reason?: DirtyStateChangeReason): Promise<Action[]> {
async submitModelDirectly(reason?: DirtyStateChangeReason, layout?: LayoutOperation): Promise<Action[]> {
if (this.diagramConfiguration.layoutKind === ServerLayoutKind.AUTOMATIC && this.layoutEngine) {
await this.layoutEngine.layout();
await this.layoutEngine.layout(layout);
}

const root = this.serializeGModel();
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@
prettier-plugin-packagejson "~2.4.6"

"@eclipse-glsp/protocol@next":
version "2.6.0-next.6"
resolved "https://registry.yarnpkg.com/@eclipse-glsp/protocol/-/protocol-2.6.0-next.6.tgz#7437694ed1e4f5ca716ba657b98af46c90abbc9a"
integrity sha512-uswJrgPNb7wwRCiqyoNOkTCqdM2S+3avXuh4/vDKxyo7w05yLkblp1foEInfYIbRmqTod05K4fAtUWEkxJcg5Q==
version "2.6.0-next.14"
resolved "https://registry.yarnpkg.com/@eclipse-glsp/protocol/-/protocol-2.6.0-next.14.tgz#954c845feaca1484a76fc53617290bfa58ff36b9"
integrity sha512-081j0/WZrUFe7/G+T2zxKRDBj0grlJ/r5pizYPP8ig7Lzq9hRqL2n1vxOoU9DUaeZcWec6MJJRm5nscomFq7IA==
dependencies:
sprotty-protocol "1.4.0"
uuid "~10.0.0"
Expand Down