Skip to content

Commit

Permalink
solved by migrating to v 2.1.0-next.303
Browse files Browse the repository at this point in the history
issue #313
  • Loading branch information
rsoika committed Jan 7, 2024
1 parent b7d9658 commit d546e42
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 232 deletions.
2 changes: 1 addition & 1 deletion open-bpmn.glsp-client/open-bpmn-glsp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}
],
"dependencies": {
"@eclipse-glsp/client": "2.0.0",
"@eclipse-glsp/client": "2.1.0-next.303",
"@open-bpmn/open-bpmn-model": "1.2.0",
"@open-bpmn/open-bpmn-properties": "1.2.0",
"balloon-css": "^0.5.0"
Expand Down
78 changes: 7 additions & 71 deletions open-bpmn.glsp-client/open-bpmn-glsp/src/bpmn-select-listeners.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
********************************************************************************/
import {
ActionDispatcher,
GLSPActionDispatcher,
GModelRoot,
ISelectionListener,
SelectAction,
TYPES,
filter,
getElements,
hasArgs
Expand All @@ -39,38 +39,12 @@ import { inject, injectable } from 'inversify';
* This selectionListener selects additional associated BoundaryEvents and BPMNLabels.
* This allows to move both independent Nodes (TaskNode and BoundaryEvent, GNode and GLabel)
*/

/**
* This is a workarround for
*
* https://github.com/eclipse-glsp/glsp/discussions/1169#discussioncomment-7704089
* https://github.com/eclipse-glsp/glsp/discussions/1160#discussioncomment-7701447
*
*/
export const ActionDispatcherFactory = Symbol("ActionDispatcherFactory");



@injectable()
export class BPMNLabelNodeSelectionListener implements ISelectionListener {
@inject(TYPES.IActionDispatcher)
protected actionDispatcher: ActionDispatcher;

/*
* WORKAROUND START
*/
@inject(ActionDispatcherFactory)
protected actionDispatcherFactory: () => GLSPActionDispatcher;
private _actionDispatcher: GLSPActionDispatcher | undefined;
get actionDispatcher(): ActionDispatcher {
if (!this._actionDispatcher) {
this._actionDispatcher = this.actionDispatcherFactory();
}
return this._actionDispatcher;
}
/*
* WORKAROUND END
*/

selectionChanged(root: Readonly<GModelRoot>, selectedElements: string[]) {
selectionChanged(root: Readonly<GModelRoot>, selectedElements: string[]): void {
const additionalSelection: string[] = [''];
// We are interested in Tasks with BoundaryEvents ...
const selectedTaskNodes = getElements(root.index, selectedElements, isTaskNode);
Expand Down Expand Up @@ -98,23 +72,11 @@ export class BPMNLabelNodeSelectionListener implements ISelectionListener {
additionalSelection.push(l);
});
}


// finally dispatch the additional elementIDs...
//this.actionDispatcher.dispatch(SelectAction.create({ selectedElementsIDs: additionalSelection }));
this.updateSelectionData(additionalSelection);
}


async updateSelectionData(additionalSelection: string[]): Promise<string[]> {
// do something
this.actionDispatcher.dispatch(SelectAction.create({ selectedElementsIDs: additionalSelection }));
return additionalSelection;
}
}



/**
* This selectionListener reacts on multiple selection. In case the selection list contains
* a Pool or a Lane, these elements are removed from the selection. This is to support
Expand All @@ -123,25 +85,8 @@ export class BPMNLabelNodeSelectionListener implements ISelectionListener {
*/
@injectable()
export class BPMNMultiNodeSelectionListener implements ISelectionListener {
// @inject(TYPES.IActionDispatcher)
// protected actionDispatcher: ActionDispatcher;

/*
* WORKAROUND START
*/
@inject(ActionDispatcherFactory)
protected actionDispatcherFactory: () => GLSPActionDispatcher;
private _actionDispatcher: GLSPActionDispatcher | undefined;
get actionDispatcher(): ActionDispatcher {
if (!this._actionDispatcher) {
this._actionDispatcher = this.actionDispatcherFactory();
}
return this._actionDispatcher;
}
/*
* WORKAROUND END
*/

@inject(TYPES.IActionDispatcher)
protected actionDispatcher: ActionDispatcher;

selectionChanged(root: Readonly<GModelRoot>, selectedElements: string[]): void {
// react only if more than one element is selected
Expand Down Expand Up @@ -170,15 +115,6 @@ export class BPMNMultiNodeSelectionListener implements ISelectionListener {
return !containerIDs.includes(element);
});
// finally dispatch the updated selected and unselected IDs...
// this.actionDispatcher.dispatch(SelectAction.create({ selectedElementsIDs: selectedElements, deselectedElementsIDs: containerIDs }));
this.updateSelectionData(selectedElements, containerIDs);
}



async updateSelectionData(addSelectIDs: string[], deselectIDs: string[]): Promise<string[]> {
// do something
this.actionDispatcher.dispatch(SelectAction.create({ selectedElementsIDs: addSelectIDs, deselectedElementsIDs: deselectIDs }));
return addSelectIDs;
this.actionDispatcher.dispatch(SelectAction.create({ selectedElementsIDs: selectedElements, deselectedElementsIDs: containerIDs }));
}
}
25 changes: 2 additions & 23 deletions open-bpmn.glsp-client/open-bpmn-glsp/src/di.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
DiamondNodeView,
GCompartment,
GCompartmentView,
GLSPActionDispatcher,
GLabel,
GLabelView,
LogLevel,
Expand Down Expand Up @@ -74,7 +73,6 @@ import {
} from './bpmn-helperlines';
import { BPMNEdgeView } from './bpmn-routing-views';
import {
ActionDispatcherFactory,
BPMNLabelNodeSelectionListener,
BPMNMultiNodeSelectionListener
} from './bpmn-select-listeners';
Expand All @@ -84,28 +82,9 @@ import {
BPMNPropertyModule
} from '@open-bpmn/open-bpmn-properties';






const bpmnDiagramModule = new ContainerModule((bind, unbind, isBound, rebind) => {
const context = { bind, unbind, isBound, rebind };

/**
* WORKAROUND START
*
* This is a workarround for
*
* https://github.com/eclipse-glsp/glsp/discussions/1169#discussioncomment-7704089
* https://github.com/eclipse-glsp/glsp/discussions/1160#discussioncomment-7701447
*
*/
bind(ActionDispatcherFactory).toFactory<GLSPActionDispatcher>(
ctx => () => ctx.container.get<GLSPActionDispatcher>(TYPES.IActionDispatcher)
);
/* WORKARROUND END */

rebind(TYPES.ILogger).to(ConsoleLogger).inSingletonScope();
rebind(TYPES.LogLevel).toConstantValue(LogLevel.warn);
bind(TYPES.ISnapper).to(BPMNElementSnapper);
Expand All @@ -116,7 +95,6 @@ const bpmnDiagramModule = new ContainerModule((bind, unbind, isBound, rebind) =>
bind(TYPES.IContextMenuItemProvider).to(DeleteElementContextMenuItemProvider);

// bind new SelectionListener for BPMNLabels and BoundaryEvents
// PROBLEMBEREICH
bind(TYPES.ISelectionListener).to(BPMNLabelNodeSelectionListener);
bind(TYPES.ISelectionListener).to(BPMNMultiNodeSelectionListener);
bind(TYPES.MouseListener).to(BPMNPropertiesMouseListener);
Expand Down Expand Up @@ -199,6 +177,7 @@ export function createBPMNDiagramContainer(...containerConfiguration: ContainerC

export function initializeBPMNDiagramContainer(container: Container,
...containerConfiguration: ContainerConfiguration): Container {
return initializeDiagramContainer(container, bpmnDiagramModule, BPMNPropertyModule, ...containerConfiguration);
//return initializeDiagramContainer(container, bpmnDiagramModule, ...containerConfiguration);
return initializeDiagramContainer(container, bpmnDiagramModule, BPMNPropertyModule, ...containerConfiguration);
//return initializeDiagramContainer(container, bpmnDiagramModule, BPMNPropertyModuleTest, ...containerConfiguration);
}
2 changes: 1 addition & 1 deletion open-bpmn.glsp-client/open-bpmn-model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"watch": "tsc -w"
},
"dependencies": {
"@eclipse-glsp/client": "2.0.0"
"@eclipse-glsp/client": "2.1.0-next.303"
}
}
2 changes: 1 addition & 1 deletion open-bpmn.glsp-client/open-bpmn-properties/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"watch": "tsc -w"
},
"dependencies": {
"@eclipse-glsp/client": "2.0.0",
"@eclipse-glsp/client": "2.1.0-next.303",
"@open-bpmn/open-bpmn-model": "1.2.0",
"@jsonforms/core": "3.0.0",
"@jsonforms/react": "3.0.0",
Expand Down
Loading

0 comments on commit d546e42

Please sign in to comment.