Skip to content

Commit

Permalink
Consume new protocol version & update TS
Browse files Browse the repository at this point in the history
#472
- Consume the new glsp-protocol version and update the code base to comply to the new action definitions

 #559
- Consume new @eclipse-glsp/config version and update to typescript 4.5.5.
- Adapt code to conform to new "strict" mode and "noImplicitOverride"
- Cleanup dev dependencies and move common dependencies into package root

#492
Update workflow builders to provide the same improved styled components as the Java GLSP server


Part of eclipse-glsp/glsp/issues/472
Part of eclipse-glsp/glsp/issues/559
Part of eclipse-glsp/glsp/issues/492

Requires eclipse-glsp/glsp-client#171

Contributed on behalf of STMicroelectronics
  • Loading branch information
tortmayr committed Mar 30, 2022
1 parent 5526a50 commit c4f547a
Show file tree
Hide file tree
Showing 81 changed files with 876 additions and 977 deletions.
10 changes: 9 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ module.exports = {
project: 'tsconfig.json'
},
rules: {
'no-shadow': 'off'
'no-shadow': 'off',
'no-restricted-imports': [
'warn',
{
name: 'sprotty-protocol',
message:
"The sprotty-protocol default exports are customized and reexported by GLSP. Please import from '@eclipse-glsp/client' instead"
}
]
}
};
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ coverage/
*.jar

/.metadata/
yarn-error.log
yarn-error.log

tsconfig.tsbuildinfo
5 changes: 1 addition & 4 deletions examples/workflow-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@
"@eclipse-glsp/server-node": "0.9.0",
"@eclipse-glsp/layout-elk": "0.9.0"
},
"devDependencies": {
"typescript": "^3.9.2"
},
"scripts": {
"clean": "rimraf lib",
"clean": "rimraf tsconfig.tsbuildinfo lib",
"build": "yarn run clean && tsc",
"test": "",
"lint": "eslint -c ../../.eslintrc.js --ext .ts,.tsx ./src",
Expand Down
37 changes: 9 additions & 28 deletions examples/workflow-server/src/graph-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { ModelTypes } from './util/model-types';
export class ActivityNode extends GNode {
nodeType: string;

static builder(): ActivityNodeBuilder {
static override builder(): ActivityNodeBuilder {
return new ActivityNodeBuilder(ActivityNode);
}
}
Expand All @@ -48,7 +48,7 @@ export class TaskNode extends GNode {
taskType: string;
references: string;

static builder(): TaskNodeBuilder {
static override builder(): TaskNodeBuilder {
return new TaskNodeBuilder(TaskNode).layout('vbox').addArgs(ArgsUtil.cornerRadius(5));
}
}
Expand All @@ -75,20 +75,12 @@ export class TaskNodeBuilder<T extends TaskNode = TaskNode> extends GNodeBuilder
}

children(): this {
this.proxy.children.push(this.createCompartment());
return this;
}

protected createCompartment(): GCompartment {
const layoutOptions: Args = {};
return new GCompartmentBuilder(GCompartment)
.type(ModelTypes.COMP_HEADER)
.id(this.proxy.id + '_header')
.layout('hbox')
.addLayoutOptions(layoutOptions)
.add(this.createCompartmentIcon())
.add(this.createCompartmentHeader())
.build();
override build(): T {
this.layout('hbox').addLayoutOption('paddingRight', 10).add(this.createCompartmentIcon()).add(this.createCompartmentHeader());
return super.build();
}

protected createCompartmentHeader(): GLabel {
Expand All @@ -100,28 +92,17 @@ export class TaskNodeBuilder<T extends TaskNode = TaskNode> extends GNodeBuilder
}

protected createCompartmentIcon(): GCompartment {
return new GCompartmentBuilder(GCompartment)
.type(ModelTypes.ICON)
return GCompartment.builder()
.id(this.proxy.id + '_icon')
.layout('stack')
.addLayoutOptions({ hAlign: 'center', resizeContainer: false })
.add(this.createCompartmentIconLabel())
.build();
}

protected createCompartmentIconLabel(): GLabel {
return new GLabelBuilder(GLabel)
.type(ModelTypes.LABEL_ICON)
.id(this.proxy.id + '_ticon')
.text(`${this.proxy.taskType.toUpperCase().charAt(0)}`)
.type(ModelTypes.ICON)
.build();
}
}

export class WeightedEdge extends GEdge {
probability?: string;

static builder(): WeightedEdgeBuilder {
static override builder(): WeightedEdgeBuilder {
return new WeightedEdgeBuilder(WeightedEdge).type(ModelTypes.WEIGHTED_EDGE);
}
}
Expand All @@ -136,7 +117,7 @@ export class WeightedEdgeBuilder<E extends WeightedEdge = WeightedEdge> extends
export class Category extends ActivityNode {
name: string;

static builder(): CategoryNodeBuilder {
static override builder(): CategoryNodeBuilder {
return new CategoryNodeBuilder(Category)
.layout('vbox')
.addLayoutOptions({ hAlign: 'center', hGrab: false, vGrab: false })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Point, Args, GNode, GModelState, ORIGIN_POINT } from '@eclipse-glsp/server-node';
import { CreateWorkflowNodeOperationHandler } from './create-workflow-node-operation-handler';
import { Args, GModelState, GNode, Point } from '@eclipse-glsp/server-node';
import { injectable } from 'inversify';
import { ActivityNode, ActivityNodeBuilder } from '../graph-extension';
import { ModelTypes } from '../util/model-types';
import { CreateWorkflowNodeOperationHandler } from './create-workflow-node-operation-handler';

@injectable()
export abstract class CreateActivityNodeHandler extends CreateWorkflowNodeOperationHandler {
Expand All @@ -27,7 +27,7 @@ export abstract class CreateActivityNodeHandler extends CreateWorkflowNodeOperat

protected builder(point: Point | undefined, modelState: GModelState): ActivityNodeBuilder {
return ActivityNode.builder()
.position(point ?? ORIGIN_POINT)
.position(point ?? Point.ORIGIN)
.type(this.elementTypeIds[0])
.nodeType(ModelTypes.toNodeType(this.elementTypeIds[0]));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { ModelTypes } from '../util/model-types';
import { CreateTaskHandler } from './create-task-handler';
import { GModelState, Point } from '@eclipse-glsp/server-node';
import { injectable } from 'inversify';
import { Point, GModelState } from '@eclipse-glsp/server-node';
import { TaskNodeBuilder } from '../graph-extension';
import { ModelTypes } from '../util/model-types';
import { CreateTaskHandler } from './create-task-handler';

@injectable()
export class CreateAutomatedTaskHandler extends CreateTaskHandler {
elementTypeIds = [ModelTypes.AUTOMATED_TASK];
label = 'Automated Task';

protected builder(point: Point | undefined, modelState: GModelState): TaskNodeBuilder {
protected override builder(point: Point | undefined, modelState: GModelState): TaskNodeBuilder {
return super.builder(point, modelState).addCssClass('automated');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Point, Args, GNode, GModelState, ORIGIN_POINT } from '@eclipse-glsp/server-node';
import { Args, ArgsUtil, GModelState, GNode, Point } from '@eclipse-glsp/server-node';
import { Category, CategoryNodeBuilder } from '../graph-extension';
import { ModelTypes } from '../util/model-types';
import { CreateWorkflowNodeOperationHandler } from './create-workflow-node-operation-handler';
Expand All @@ -29,8 +29,9 @@ export class CreateCategoryHandler extends CreateWorkflowNodeOperationHandler {
protected builder(point: Point | undefined, modelState: GModelState): CategoryNodeBuilder {
return Category.builder()
.type(this.elementTypeIds[0])
.position(point ?? ORIGIN_POINT)
.position(point ?? Point.ORIGIN)
.name(this.label.replace(' ', '') + this.modelState.index.getAllByClass(Category).length)
.addArgs(ArgsUtil.cornerRadius(5))
.children();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { ModelTypes } from '../util/model-types';
import { injectable } from 'inversify';
import { CreateActivityNodeHandler } from './create-activity-node-handler';
import { GModelState, Point } from '@eclipse-glsp/server-node';
import { injectable } from 'inversify';
import { ActivityNodeBuilder } from '../graph-extension';
import { ModelTypes } from '../util/model-types';
import { CreateActivityNodeHandler } from './create-activity-node-handler';

@injectable()
export class CreateDecisionNodeHandler extends CreateActivityNodeHandler {
elementTypeIds = [ModelTypes.DECISION_NODE];
label = 'Decision Node';

protected builder(point: Point | undefined, modelState: GModelState): ActivityNodeBuilder {
protected override builder(point: Point | undefined, modelState: GModelState): ActivityNodeBuilder {
return super.builder(point, modelState).addCssClass('decision');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Point, GModelState } from '@eclipse-glsp/server-node';
import { CreateActivityNodeHandler } from './create-activity-node-handler';
import { GModelState, Point } from '@eclipse-glsp/server-node';
import { injectable } from 'inversify';
import { ActivityNodeBuilder } from '../graph-extension';
import { CreateActivityNodeHandler } from './create-activity-node-handler';

@injectable()
export abstract class CreateForkOrJoinNodeHandler extends CreateActivityNodeHandler {
protected builder(point: Point | undefined, modelState: GModelState): ActivityNodeBuilder {
protected override builder(point: Point | undefined, modelState: GModelState): ActivityNodeBuilder {
return super.builder(point, modelState).addCssClass('forkOrJoin').size(10, 50);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { ModelTypes } from '../util/model-types';
import { CreateTaskHandler } from './create-task-handler';
import { GModelState, Point } from '@eclipse-glsp/server-node';
import { injectable } from 'inversify';
import { Point, GModelState } from '@eclipse-glsp/server-node';
import { TaskNodeBuilder } from '../graph-extension';
import { ModelTypes } from '../util/model-types';
import { CreateTaskHandler } from './create-task-handler';

@injectable()
export class CreateManualTaskHandler extends CreateTaskHandler {
elementTypeIds = [ModelTypes.MANUAL_TASK];
label = 'Manual Task';

protected builder(point: Point | undefined, modelState: GModelState): TaskNodeBuilder {
protected override builder(point: Point | undefined, modelState: GModelState): TaskNodeBuilder {
return super.builder(point, modelState).addCssClass('manual');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { ModelTypes } from '../util/model-types';
import { injectable } from 'inversify';
import { CreateActivityNodeHandler } from './create-activity-node-handler';
import { GModelState, Point } from '@eclipse-glsp/server-node';
import { injectable } from 'inversify';
import { ActivityNodeBuilder } from '../graph-extension';
import { ModelTypes } from '../util/model-types';
import { CreateActivityNodeHandler } from './create-activity-node-handler';

@injectable()
export class CreateMergeNodeHandler extends CreateActivityNodeHandler {
elementTypeIds = [ModelTypes.MERGE_NODE];
label = 'Merge Node';

protected builder(point: Point | undefined, modelState: GModelState): ActivityNodeBuilder {
protected override builder(point: Point | undefined, modelState: GModelState): ActivityNodeBuilder {
return super.builder(point, modelState).addCssClass('merge');
}
}
8 changes: 4 additions & 4 deletions examples/workflow-server/src/handler/create-task-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { CreateWorkflowNodeOperationHandler } from './create-workflow-node-operation-handler';
import { injectable } from 'inversify';
import { Args, ORIGIN_POINT, Point } from '@eclipse-glsp/protocol';
import { Args, Point } from '@eclipse-glsp/protocol';
import { GModelState, GNode } from '@eclipse-glsp/server-node';
import { injectable } from 'inversify';
import { TaskNode, TaskNodeBuilder } from '../graph-extension';
import { ModelTypes } from '../util/model-types';
import { CreateWorkflowNodeOperationHandler } from './create-workflow-node-operation-handler';

@injectable()
export abstract class CreateTaskHandler extends CreateWorkflowNodeOperationHandler {
Expand All @@ -28,7 +28,7 @@ export abstract class CreateTaskHandler extends CreateWorkflowNodeOperationHandl

protected builder(point: Point | undefined, modelState: GModelState): TaskNodeBuilder {
return TaskNode.builder()
.position(point ?? ORIGIN_POINT)
.position(point ?? Point.ORIGIN)
.addCssClass('task')
.name(this.label.replace(' ', '') + this.modelState.index.getAllByClass(TaskNode).length)
.type(this.elementTypeIds[0])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ import {
GModelState,
Point
} from '@eclipse-glsp/server-node';
import { injectable, inject } from 'inversify';
import { inject, injectable } from 'inversify';
import { Category } from '../graph-extension';
import { ModelTypes } from '../util/model-types';
import { GridSnapper } from './grid-snapper';

@injectable()
export abstract class CreateWorkflowNodeOperationHandler extends CreateNodeOperationHandler {
@inject(GModelState)
protected modelState: GModelState;
protected override modelState: GModelState;

getLocation(operation: CreateNodeOperation): Point | undefined {
override getLocation(operation: CreateNodeOperation): Point | undefined {
return GridSnapper.snap(operation.location);
}

getContainer(operation: CreateNodeOperation): GModelElement | undefined {
override getContainer(operation: CreateNodeOperation): GModelElement | undefined {
const container = super.getContainer(operation);

if (container instanceof Category) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { injectable } from 'inversify';

@injectable()
export class WorkflowLayoutConfigurator extends AbstractLayoutConfigurator {
protected graphOptions(graph: GGraph): LayoutOptions | undefined {
protected override graphOptions(graph: GGraph): LayoutOptions | undefined {
return {
'elk.algorithm': 'layered'
};
Expand Down
Loading

0 comments on commit c4f547a

Please sign in to comment.