Skip to content

Commit

Permalink
first draft
Browse files Browse the repository at this point in the history
Issue imixs#216
  • Loading branch information
rsoika committed Mar 19, 2023
1 parent bc72663 commit b85817d
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 35 deletions.
50 changes: 50 additions & 0 deletions open-bpmn.glsp-client/open-bpmn-glsp/src/bpmn-property-actions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/********************************************************************************
* Copyright (c) 2022 Imixs Software Solutions GmbH and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Action } from '@eclipse-glsp/protocol';
import { injectable } from 'inversify';
import {
IActionHandler
} from 'sprotty';

/****************************************************************************
* This module provides BPMN action listeners for custom behavior.
*
****************************************************************************/

export interface BPMNPropertyAction extends Action {
kind: typeof BPMNPropertyAction.KIND;
}

export namespace BPMNPropertyAction {
export const KIND = 'properties';

export function is(object: any): object is BPMNPropertyAction {
return Action.hasKind(object, KIND);
}

export function create(): BPMNPropertyAction {
return { kind: KIND };
}
}

@injectable()
export class BPMNPropertyActionHandler implements IActionHandler {
handle(action: BPMNPropertyAction): void | BPMNPropertyAction {
console.log('--------> custom action arrived');
// implement your custom logic to handle the action
// Optionally issue a response action
}
}
9 changes: 7 additions & 2 deletions open-bpmn.glsp-client/open-bpmn-glsp/src/di.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import {
boundsFeature, CircularNodeView, configureCommand, configureDefaultModelElements,
configureModelElement, configureView, ConsoleLogger,
boundsFeature, CircularNodeView, configureActionHandler, configureCommand,
configureDefaultModelElements, configureModelElement, configureView, ConsoleLogger,
createDiagramContainer,
DeleteElementContextMenuItemProvider,
DiamondNodeView,
Expand Down Expand Up @@ -51,6 +51,8 @@ import {

import bpmnPropertyModule from '@open-bpmn/open-bpmn-properties';

import { BPMNPropertyAction, BPMNPropertyActionHandler } from './bpmn-property-actions';

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

Expand Down Expand Up @@ -121,6 +123,9 @@ const bpmnDiagramModule = new ContainerModule((bind, unbind, isBound, rebind) =>
configureModelElement(context, 'messageFlow', BPMNEdge, BPMNEdgeView);
configureModelElement(context, 'association', BPMNEdge, BPMNEdgeView);

// Action BPMN Property Action Handler
configureActionHandler(context, BPMNPropertyAction.KIND, BPMNPropertyActionHandler);

});

/*
Expand Down
4 changes: 3 additions & 1 deletion open-bpmn.glsp-client/open-bpmn-glsp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import createBPMNDiagramContainer from './di.config';

export * from './bpmn-element-views';
export * from './bpmn-property-actions';
export * from './bpmn-routing-views';

export { createBPMNDiagramContainer };


Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { ContainerContext, GLSPClientContribution, GLSPTheiaFrontendModule } from '@eclipse-glsp/theia-integration';
import { CommandContribution, MenuContribution } from '@theia/core';
import { DiagramConfiguration } from 'sprotty-theia';
import { BPMNLanguage } from '../common/bpmn-language';
import { BPMNDiagramConfiguration } from './diagram/bpmn-diagram-configuration';
import { BPMNGLSPClientContribution } from './bpmn-glsp-client-contribution';
import { BPMNPropertiesCommandContribution, BPMNPropertiesMenuContribution } from './bpmn-property-commands';
import { BPMNDiagramConfiguration } from './diagram/bpmn-diagram-configuration';

export class BPMNTheiaFrontendModule extends GLSPTheiaFrontendModule {
protected override enableCopyPaste = true;
Expand All @@ -26,44 +28,18 @@ export class BPMNTheiaFrontendModule extends GLSPTheiaFrontendModule {
bindDiagramConfiguration(context: ContainerContext): void {
context.bind(DiagramConfiguration).to(BPMNDiagramConfiguration);
}
override bindGLSPClientContribution(context: ContainerContext): void {
context.bind(GLSPClientContribution).to(BPMNGLSPClientContribution);
}
}

export default new BPMNTheiaFrontendModule();

// --
/*
export class WorkflowTheiaFrontendModule extends GLSPTheiaFrontendModule {
protected override enableCopyPaste = true;
bindDiagramConfiguration(context: ContainerContext): void {
context.bind(DiagramConfiguration).to(WorkflowDiagramConfiguration);
}
readonly diagramLanguage = WorkflowLanguage;

override configure(context: ContainerContext): void {
// Custom workflow commands and menus
context.bind(CommandContribution).to(WorkflowTaskEditCommandContribution);
context.bind(MenuContribution).to(WorkflowTaskEditMenuContribution);
context.bind(CommandContribution).to(WorkflowNavigationCommandContribution);
context.bind(MenuContribution).to(WorkflowNavigationMenuContribution);
context.bind(KeybindingContext).to(WorkflowDiagramKeybindingContext);
context.bind(KeybindingContribution).to(WorkflowKeybindingContribution);
context.bind(CommandContribution).to(BPMNPropertiesCommandContribution);
context.bind(MenuContribution).to(BPMNPropertiesMenuContribution);

// Example for a command that navigates to an element in a diagram with a query resolved by the server
context.bind(CommandContribution).to(ExampleNavigationCommandContribution).inSingletonScope();
// Readonly workflow diagram view
context.bind(WorkflowDiagramReadonlyViewContribution).toSelf().inSingletonScope();
context.bind(MenuContribution).toService(WorkflowDiagramReadonlyViewContribution);
context.bind(CommandContribution).toService(WorkflowDiagramReadonlyViewContribution);
}

override bindGLSPClientContribution(context: ContainerContext): void {
context.bind(GLSPClientContribution).to(WorkflowGLSPClientContribution);
context.bind(GLSPClientContribution).to(BPMNGLSPClientContribution);
}
}
*/

export default new BPMNTheiaFrontendModule();

Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/********************************************************************************
* Copyright (c) 2020-2022 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { NavigateAction } from '@eclipse-glsp/client';
import { GLSPCommandHandler, GLSPContextMenu } from '@eclipse-glsp/theia-integration';
import {
BPMNPropertyAction
} from '@open-bpmn/open-bpmn-glsp';
import { CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry } from '@theia/core';
import { ApplicationShell } from '@theia/core/lib/browser';
import { inject, injectable } from '@theia/core/shared/inversify';
/**
* This module defines different commands and menu actions that fire a specific action.
* These actions can be handled by the server or client part.
*
* Note! the command contributions must be registered in the BPMNTheiaFrontendModule
*
*/
export namespace PropertyPanelCommands {
export const PROPERTIES_CLOSE = 'glsp-bpmn-properties-close';
export const PROPERTIES_OPEN = 'glsp-bpmn-properties-open';
}

@injectable()
export class BPMNPropertiesCommandContribution implements CommandContribution {
@inject(ApplicationShell) protected readonly shell: ApplicationShell;
registerCommands(commands: CommandRegistry): void {
// register commands...
commands.registerCommand(
{ id: PropertyPanelCommands.PROPERTIES_OPEN, label: 'Open Properties' },
new GLSPCommandHandler(this.shell, {
actions: () => [BPMNPropertyAction.create()],
isEnabled: context => context.selectedElements.length === 1
})
);

commands.registerCommand(
{ id: PropertyPanelCommands.PROPERTIES_CLOSE, label: 'Close Properties' },
new GLSPCommandHandler(this.shell, {
actions: () => [NavigateAction.create('properties')],
isEnabled: context => context.selectedElements.length === 1
})
);
}
}

@injectable()
export class BPMNPropertiesMenuContribution implements MenuContribution {
// static readonly NAVIGATION = GLSPContextMenu.MENU_PATH.concat('navigate');
// static readonly NIX = GLSPContextMenu.MENU_PATH;
registerMenus(menus: MenuModelRegistry): void {

menus.registerMenuAction(GLSPContextMenu.MENU_PATH.concat('z'), {
commandId: PropertyPanelCommands.PROPERTIES_OPEN,
label: 'Open Properties'
});
menus.registerMenuAction(GLSPContextMenu.MENU_PATH.concat('z'), {
commandId: PropertyPanelCommands.PROPERTIES_CLOSE,
label: 'Close Properties'
});

}
}

0 comments on commit b85817d

Please sign in to comment.