Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pimp integrations #489

Merged
merged 1 commit into from
Feb 19, 2024
Merged
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
2 changes: 1 addition & 1 deletion integration/eclipse/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DiagramLoader } from '@eclipse-glsp/client';

import { IvyBaseJsonrpcGLSPClient } from '@axonivy/process-editor';
import { getParameters } from '@eclipse-glsp/ide';
import { IvyBaseJsonrpcGLSPClient } from '@axonivy/process-editor';
import { ApplicationIdProvider, GLSPClient, GLSPWebSocketProvider } from '@eclipse-glsp/protocol';
import { MessageConnection } from 'vscode-jsonrpc';

Expand Down
8 changes: 6 additions & 2 deletions integration/eclipse/src/startup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IVY_TYPES, ToolBar } from '@axonivy/process-editor';
import { EnableInscriptionAction } from '@axonivy/process-editor-inscription';
import { EnableViewportAction, ShowGridAction, SwitchThemeAction } from '@axonivy/process-editor-protocol';
import { EnableViewportAction, ShowGridAction, SwitchThemeAction, UpdatePaletteItems } from '@axonivy/process-editor-protocol';
import { EnableToolPaletteAction, GLSPActionDispatcher, IDiagramStartup, TYPES } from '@eclipse-glsp/client';
import { ContainerModule, inject, injectable } from 'inversify';
import { IvyDiagramOptions } from './di.config';
Expand All @@ -22,11 +22,15 @@ export class EclipseDiagramStartup implements IDiagramStartup {
@inject(TYPES.IDiagramOptions)
protected options: IvyDiagramOptions;

async postRequestModel(): Promise<void> {
async preRequestModel(): Promise<void> {
this.actionDispatcher.dispatch(EnableToolPaletteAction.create());
this.actionDispatcher.dispatch(EnableViewportAction.create());
this.actionDispatcher.dispatch(SwitchThemeAction.create({ theme: this.options.theme }));
}

async postRequestModel(): Promise<void> {
this.actionDispatcher.dispatch(ShowGridAction.create({ show: this.options.showGrid }));
this.actionDispatcher.dispatch(UpdatePaletteItems.create());
}

async postModelInitialization(): Promise<void> {
Expand Down
8 changes: 6 additions & 2 deletions integration/standalone/src/startup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnableInscriptionAction } from '@axonivy/process-editor-inscription';
import { EnableViewportAction, SwitchThemeAction } from '@axonivy/process-editor-protocol';
import { EnableViewportAction, SwitchThemeAction, UpdatePaletteItems } from '@axonivy/process-editor-protocol';
import {
EnableToolPaletteAction,
GLSPActionDispatcher,
Expand All @@ -25,12 +25,16 @@ export class StandaloneDiagramStartup implements IDiagramStartup {
@inject(TYPES.IDiagramOptions)
protected options: IvyDiagramOptions;

async postRequestModel(): Promise<void> {
async preRequestModel(): Promise<void> {
this.actionDispatcher.dispatch(EnableToolPaletteAction.create());
this.actionDispatcher.dispatch(EnableViewportAction.create());
this.actionDispatcher.dispatch(SwitchThemeAction.create({ theme: this.options.theme }));
}

async postRequestModel(): Promise<void> {
this.actionDispatcher.dispatch(UpdatePaletteItems.create());
}

async postModelInitialization(): Promise<void> {
MonacoUtil.initStandalone(editorWorker).then(() => MonacoEditorUtil.initMonaco(reactMonaco, this.options.theme));
this.actionDispatcher.dispatch(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
Action,
EnableToolPaletteAction,
GLSPActionDispatcher,
IActionHandler,
ICommand,
Expand All @@ -11,7 +10,7 @@ import {
} from '@eclipse-glsp/client';
import { injectable, inject } from 'inversify';
import { ShowQuickActionMenuAction } from '../quick-action-menu-ui';
import { UpdateColorPaletteAction } from '@axonivy/process-editor-protocol';
import { UpdateColorPaletteAction, UpdatePaletteItems } from '@axonivy/process-editor-protocol';

@injectable()
export class ColorPaletteHandler implements IActionHandler {
Expand All @@ -24,7 +23,7 @@ export class ColorPaletteHandler implements IActionHandler {
}

handle(action: Action): void | Action | ICommand {
if (EnableToolPaletteAction.is(action)) {
if (UpdatePaletteItems.is(action)) {
this.updateColorPalette();
}
if (UpdateColorPaletteAction.is(action)) {
Expand Down
15 changes: 4 additions & 11 deletions packages/editor/src/ui-tools/quick-action/di.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import './quick-action.css';

import {
EnableToolPaletteAction,
FeatureModule,
RemoveMarqueeAction,
TYPES,
bindAsService,
configureActionHandler
} from '@eclipse-glsp/client';
import { FeatureModule, RemoveMarqueeAction, TYPES, bindAsService, configureActionHandler } from '@eclipse-glsp/client';
import { interfaces } from 'inversify';

import { UpdateColorPaletteAction } from '@axonivy/process-editor-protocol';
import { UpdateColorPaletteAction, UpdatePaletteItems } from '@axonivy/process-editor-protocol';
import { IVY_TYPES } from '../../types';
import { SelectColorQuickActionProvider } from './color/action';
import { ColorPaletteHandler } from './color/action-handler';
Expand Down Expand Up @@ -62,15 +55,15 @@ export function configureQuickActionProviders(context: { bind: interfaces.Bind }
export function configureColorQuickActionProviders(context: { bind: interfaces.Bind; isBound: interfaces.IsBound }): void {
context.bind(ColorPaletteHandler).toSelf().inSingletonScope();
context.bind(IVY_TYPES.ColorPalette).toService(ColorPaletteHandler);
configureActionHandler(context, EnableToolPaletteAction.KIND, ColorPaletteHandler);
configureActionHandler(context, UpdatePaletteItems.KIND, ColorPaletteHandler);
configureActionHandler(context, UpdateColorPaletteAction.KIND, ColorPaletteHandler);
context.bind(IVY_TYPES.QuickActionProvider).to(SelectColorQuickActionProvider);
}

export function configureTypeQuickActionProviders(context: { bind: interfaces.Bind; isBound: interfaces.IsBound }): void {
context.bind(TypesPaletteHandler).toSelf().inSingletonScope();
context.bind(IVY_TYPES.ActivityTypesPalette).toService(TypesPaletteHandler);
configureActionHandler(context, EnableToolPaletteAction.KIND, TypesPaletteHandler);
configureActionHandler(context, UpdatePaletteItems.KIND, TypesPaletteHandler);
context.bind(IVY_TYPES.QuickActionProvider).to(SelectActivityTypeQuickActionProvider);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { UpdatePaletteItems } from '@axonivy/process-editor-protocol';
import {
Action,
EnableToolPaletteAction,
GLSPActionDispatcher,
IActionHandler,
ICommand,
Expand All @@ -22,7 +22,7 @@ export class TypesPaletteHandler implements IActionHandler {
}

handle(action: Action): void | Action | ICommand {
if (EnableToolPaletteAction.is(action)) {
if (UpdatePaletteItems.is(action)) {
this.updateActivityTypePalette();
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/ui-tools/tool-bar/di.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { interfaces } from 'inversify';
import { IVY_TYPES } from '../../types';

import { CustomIconToggleAction } from '@axonivy/process-editor-protocol';
import { CustomIconToggleAction, UpdatePaletteItems } from '@axonivy/process-editor-protocol';
import { OptionsButtonProvider } from './button';
import { ElementsPaletteHandler } from './node/action-handler';
import {
Expand Down Expand Up @@ -54,7 +54,7 @@ const ivyToolBarModule = new FeatureModule(

function configureToolBarButtons(context: { bind: interfaces.Bind; isBound: interfaces.IsBound }): void {
context.bind(ElementsPaletteHandler).toSelf().inSingletonScope();
configureActionHandler(context, EnableToolPaletteAction.KIND, ElementsPaletteHandler);
configureActionHandler(context, UpdatePaletteItems.KIND, ElementsPaletteHandler);
context.bind(IVY_TYPES.ToolBarButtonProvider).to(AllElementsButtonProvider);
context.bind(IVY_TYPES.ToolBarButtonProvider).to(EventsButtonProvider);
context.bind(IVY_TYPES.ToolBarButtonProvider).to(GatewaysButtonProvider);
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/ui-tools/tool-bar/node/action-handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
Action,
EnableToolPaletteAction,
GLSPActionDispatcher,
IActionHandler,
ICommand,
Expand All @@ -11,6 +10,7 @@ import {
} from '@eclipse-glsp/client';
import { injectable, inject } from 'inversify';
import { ToolBar } from '../tool-bar';
import { UpdatePaletteItems } from '@axonivy/process-editor-protocol';

@injectable()
export class ElementsPaletteHandler implements IActionHandler {
Expand All @@ -23,7 +23,7 @@ export class ElementsPaletteHandler implements IActionHandler {
}

handle(action: Action): void | Action | ICommand {
if (EnableToolPaletteAction.is(action)) {
if (UpdatePaletteItems.is(action)) {
this.updateElementPalette();
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/protocol/src/action/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export * from './insert-extension';
export * from './jump';
export * from './model';
export * from './outline';
export * from './palette-items';
export * from './start';
export * from './theme';
export * from './types';
Expand Down
17 changes: 17 additions & 0 deletions packages/protocol/src/action/palette-items.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Action } from '@eclipse-glsp/protocol';

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

export namespace UpdatePaletteItems {
export const KIND = 'updatePaletteItems';

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

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