forked from imixs/open-bpmn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue imixs#216
- Loading branch information
Showing
5 changed files
with
144 additions
and
35 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
open-bpmn.glsp-client/open-bpmn-glsp/src/bpmn-property-actions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
open-bpmn.glsp-client/open-bpmn-theia/src/browser/bpmn-property-commands.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
}); | ||
|
||
} | ||
} |