Skip to content

Commit

Permalink
Align ActionDispatcher API (GLSP-1416)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivy-lli committed Nov 25, 2024
1 parent 530b419 commit e4912f1
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 44 deletions.
8 changes: 4 additions & 4 deletions integration/eclipse/src/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import type { ToolBar } from '@axonivy/process-editor';
import { IVY_TYPES } from '@axonivy/process-editor';
import { EnableInscriptionAction } from '@axonivy/process-editor-inscription';
import { EnableViewportAction, SwitchThemeAction, UpdatePaletteItems } from '@axonivy/process-editor-protocol';
import type { IDiagramStartup} from '@eclipse-glsp/client';
import { EnableToolPaletteAction, GLSPActionDispatcher, ShowGridAction, TYPES } from '@eclipse-glsp/client';
import type { IActionDispatcher, IDiagramStartup } from '@eclipse-glsp/client';
import { EnableToolPaletteAction, ShowGridAction, TYPES } from '@eclipse-glsp/client';
import { ContainerModule, inject, injectable } from 'inversify';
import type { IvyDiagramOptions } from './di.config';

import './index.css';

@injectable()
export class EclipseDiagramStartup implements IDiagramStartup {
@inject(GLSPActionDispatcher)
protected actionDispatcher: GLSPActionDispatcher;
@inject(TYPES.IActionDispatcher)
protected actionDispatcher: IActionDispatcher;

@inject(IVY_TYPES.ToolBar)
protected toolBar: ToolBar;
Expand Down
5 changes: 3 additions & 2 deletions integration/standalone/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { MonacoEditorUtil } from '@axonivy/process-editor-inscription-view';
import { IvyBaseJsonrpcGLSPClient, SwitchThemeActionHandler } from '@axonivy/process-editor';
import type { ThemeMode } from '@axonivy/process-editor-protocol';
import { DiagramLoader, EditMode, GLSPActionDispatcher, GLSPWebSocketProvider, MessageAction, StatusAction } from '@eclipse-glsp/client';
import type { IActionDispatcher } from '@eclipse-glsp/client';
import { DiagramLoader, EditMode, GLSPWebSocketProvider, MessageAction, StatusAction, TYPES } from '@eclipse-glsp/client';
import { ApplicationIdProvider, GLSPClient } from '@eclipse-glsp/protocol';
import type { Container } from 'inversify';
import type { MessageConnection } from 'vscode-jsonrpc';
Expand Down Expand Up @@ -63,7 +64,7 @@ async function initialize(connectionProvider: MessageConnection, isReconnecting
}
});

const actionDispatcher = container.get(GLSPActionDispatcher);
const actionDispatcher = container.get<IActionDispatcher>(TYPES.IActionDispatcher);
if (isReconnecting) {
const message = `Connection to the ${id} glsp server got closed. Connection was successfully re-established.`;
const timeout = 5000;
Expand Down
8 changes: 4 additions & 4 deletions integration/standalone/src/startup.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { EnableInscriptionAction } from '@axonivy/process-editor-inscription';
import { EnableViewportAction, SwitchThemeAction, UpdatePaletteItems } from '@axonivy/process-editor-protocol';
import type { IDiagramStartup } from '@eclipse-glsp/client';
import { EnableToolPaletteAction, GLSPActionDispatcher, NavigationTarget, SelectAction, TYPES } from '@eclipse-glsp/client';
import type { IActionDispatcher, IDiagramStartup } from '@eclipse-glsp/client';
import { EnableToolPaletteAction, NavigationTarget, SelectAction, TYPES } from '@eclipse-glsp/client';
import { ContainerModule, inject, injectable } from 'inversify';
import type { IvyDiagramOptions } from './di.config';
import './index.css';

@injectable()
export class StandaloneDiagramStartup implements IDiagramStartup {
@inject(GLSPActionDispatcher)
protected actionDispatcher: GLSPActionDispatcher;
@inject(TYPES.IActionDispatcher)
protected actionDispatcher: IActionDispatcher;

@inject(TYPES.IDiagramOptions)
protected options: IvyDiagramOptions;
Expand Down
5 changes: 3 additions & 2 deletions integration/viewer/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IvyBaseJsonrpcGLSPClient, SwitchThemeActionHandler } from '@axonivy/process-editor';
import type { ThemeMode } from '@axonivy/process-editor-protocol';
import { DiagramLoader, EditMode, GLSPActionDispatcher, GLSPWebSocketProvider, MessageAction, StatusAction } from '@eclipse-glsp/client';
import type { IActionDispatcher } from '@eclipse-glsp/client';
import { DiagramLoader, EditMode, GLSPWebSocketProvider, MessageAction, StatusAction, TYPES } from '@eclipse-glsp/client';
import { ApplicationIdProvider, GLSPClient } from '@eclipse-glsp/protocol';
import type { Container } from 'inversify';
import type { MessageConnection } from 'vscode-jsonrpc';
Expand Down Expand Up @@ -59,7 +60,7 @@ async function initialize(connectionProvider: MessageConnection, isReconnecting
}
});

const actionDispatcher = container.get(GLSPActionDispatcher);
const actionDispatcher = container.get<IActionDispatcher>(TYPES.IActionDispatcher);
if (isReconnecting) {
const message = `Connection to the ${id} glsp server got closed. Connection was successfully re-established.`;
const timeout = 5000;
Expand Down
8 changes: 4 additions & 4 deletions integration/viewer/src/startup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EnableViewportAction, MoveIntoViewportAction, SetViewportZoomAction, SwitchThemeAction } from '@axonivy/process-editor-protocol';
import type { Action, IDiagramStartup } from '@eclipse-glsp/client';
import { CenterAction, GLSPActionDispatcher, NavigationTarget, SelectAction, TYPES } from '@eclipse-glsp/client';
import type { Action, IActionDispatcher, IDiagramStartup } from '@eclipse-glsp/client';
import { CenterAction, NavigationTarget, SelectAction, TYPES } from '@eclipse-glsp/client';
import type { interfaces } from 'inversify';
import { ContainerModule, inject, injectable } from 'inversify';
import type { IvyDiagramOptions } from './di.config';
Expand All @@ -10,8 +10,8 @@ const ContainerSymbol = Symbol('ContainerSymbol');

@injectable()
export class ViewerDiagramStartup implements IDiagramStartup {
@inject(GLSPActionDispatcher)
protected actionDispatcher: GLSPActionDispatcher;
@inject(TYPES.IActionDispatcher)
protected actionDispatcher: IActionDispatcher;

@inject(TYPES.IDiagramOptions)
protected options: IvyDiagramOptions;
Expand Down
6 changes: 3 additions & 3 deletions packages/editor/src/jump/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
isViewport,
Viewport,
TYPES,
GLSPActionDispatcher,
SetViewportAction
SetViewportAction,
type IActionDispatcher
} from '@eclipse-glsp/client';
import { SelectAllAction } from '@eclipse-glsp/protocol';
import { injectable, inject } from 'inversify';
Expand All @@ -19,7 +19,7 @@ import { JumpAction } from '@axonivy/process-editor-protocol';

@injectable()
export class JumpActionHandler implements IActionHandler {
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: GLSPActionDispatcher;
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: IActionDispatcher;
@inject(EditorContextService) protected readonly editorContext: EditorContextService;
private jumpStack: Map<string, Viewport> = new Map();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import {
Action,
GLSPActionDispatcher,
IActionHandler,
ICommand,
PaletteItem,
RequestContextActions,
SetContextActions,
TYPES
TYPES,
type IActionDispatcher
} from '@eclipse-glsp/client';
import { injectable, inject } from 'inversify';
import { ShowQuickActionMenuAction } from '../quick-action-menu-ui';
import { UpdateColorPaletteAction, UpdatePaletteItems } from '@axonivy/process-editor-protocol';

@injectable()
export class ColorPaletteHandler implements IActionHandler {
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: GLSPActionDispatcher;
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: IActionDispatcher;

protected paletteItems: PaletteItem[] = [];

Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/ui-tools/quick-action/color/action.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Action, GLSPActionDispatcher, PaletteItem, GModelElement, TYPES } from '@eclipse-glsp/client';
import { Action, PaletteItem, GModelElement, TYPES, type IActionDispatcher } from '@eclipse-glsp/client';
import { QuickAction, QuickActionProvider } from '../quick-action';
import { ShowQuickActionMenuAction } from '../quick-action-menu-ui';
import { injectable, inject } from 'inversify';
Expand All @@ -11,7 +11,7 @@ import { LaneTypes } from '../../../diagram/view-types';
@injectable()
export class SelectColorQuickActionProvider implements QuickActionProvider {
@inject(IVY_TYPES.ColorPalette) protected readonly colors: ColorPaletteHandler;
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: GLSPActionDispatcher;
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: IActionDispatcher;

singleQuickAction(element: GModelElement): QuickAction | undefined {
if (element.type === LaneTypes.POOL) {
Expand Down
6 changes: 3 additions & 3 deletions packages/editor/src/ui-tools/quick-action/info/action.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {
GArgument,
GIssueMarker,
GLSPActionDispatcher,
isWithEditableLabel,
JsonAny,
GChildElement,
GEdge,
GModelElement,
TYPES,
hasArgs
hasArgs,
type IActionDispatcher
} from '@eclipse-glsp/client';
import { QuickAction, SingleQuickActionProvider } from '../quick-action';
import { ShowInfoQuickActionMenuAction } from '../quick-action-menu-ui';
Expand All @@ -20,7 +20,7 @@ import { IvyIcons } from '@axonivy/ui-icons';

@injectable()
export class InfoQuickActionProvider extends SingleQuickActionProvider {
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: GLSPActionDispatcher;
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: IActionDispatcher;
@inject(IVY_TYPES.IvyViewerOptions) protected readonly options: IvyViewerOptions;

singleQuickAction(element: GModelElement): QuickAction | undefined {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { UpdatePaletteItems } from '@axonivy/process-editor-protocol';
import {
Action,
GLSPActionDispatcher,
IActionHandler,
ICommand,
PaletteItem,
RequestContextActions,
SetContextActions,
TYPES
TYPES,
type IActionDispatcher
} from '@eclipse-glsp/client';
import { injectable, inject } from 'inversify';

@injectable()
export class TypesPaletteHandler implements IActionHandler {
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: GLSPActionDispatcher;
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: IActionDispatcher;

protected paletteItems: PaletteItem[] = [];

Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/ui-tools/quick-action/types/action.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Action, GLSPActionDispatcher, PaletteItem, GModelElement, TYPES } from '@eclipse-glsp/client';
import { Action, PaletteItem, GModelElement, TYPES, type IActionDispatcher } from '@eclipse-glsp/client';
import { QuickAction, SingleQuickActionProvider } from '../quick-action';
import { ShowQuickActionMenuAction } from '../quick-action-menu-ui';
import { injectable, inject } from 'inversify';
Expand All @@ -11,7 +11,7 @@ import { ChangeActivityTypeOperation } from '@axonivy/process-editor-protocol';
@injectable()
export class SelectActivityTypeQuickActionProvider extends SingleQuickActionProvider {
@inject(IVY_TYPES.ActivityTypesPalette) protected readonly types: TypesPaletteHandler;
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: GLSPActionDispatcher;
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: IActionDispatcher;

singleQuickAction(element: GModelElement): QuickAction | undefined {
if (isUnwrapable(element)) {
Expand Down
6 changes: 3 additions & 3 deletions packages/editor/src/ui-tools/tool-bar/node/action-handler.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import {
Action,
GLSPActionDispatcher,
IActionHandler,
ICommand,
PaletteItem,
RequestContextActions,
SetContextActions,
TYPES
TYPES,
type IActionDispatcher
} 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 {
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: GLSPActionDispatcher;
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: IActionDispatcher;

protected paletteItems: Array<PaletteItem> = [];
protected extensionItems: Promise<Array<PaletteItem>>;
Expand Down
6 changes: 3 additions & 3 deletions packages/editor/src/ui-tools/tool-bar/tool-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
EditorContextService,
EnableDefaultToolsAction,
EnableToolPaletteAction,
GLSPActionDispatcher,
IActionHandler,
ICommand,
IEditModeListener,
Expand All @@ -15,7 +14,8 @@ import {
SelectionService,
SetUIExtensionVisibilityAction,
TYPES,
isNotUndefined
isNotUndefined,
type IActionDispatcher
} from '@eclipse-glsp/client';
import { inject, injectable, multiInject, postConstruct } from 'inversify';

Expand Down Expand Up @@ -44,7 +44,7 @@ const CLICKED_CSS_CLASS = 'clicked';
export class ToolBar extends GLSPAbstractUIExtension implements IActionHandler, IEditModeListener, ISelectionListener {
static readonly ID = 'ivy-tool-bar';

@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: GLSPActionDispatcher;
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: IActionDispatcher;
@inject(SelectionService) protected readonly selectionService: SelectionService;
@inject(EditorContextService) protected readonly editorContext: EditorContextService;
@multiInject(IVY_TYPES.ToolBarButtonProvider) protected toolBarButtonProvider: ToolBarButtonProvider[];
Expand Down
6 changes: 3 additions & 3 deletions packages/editor/src/ui-tools/viewport/viewport-bar.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
Action,
EditorContextService,
GLSPActionDispatcher,
IActionHandler,
ICommand,
isViewport,
Expand All @@ -10,7 +9,8 @@ import {
SetViewportAction,
TYPES,
SelectionService,
GLSPAbstractUIExtension
GLSPAbstractUIExtension,
type IActionDispatcher
} from '@eclipse-glsp/client';
import { inject, injectable } from 'inversify';
import { CenterButton, FitToScreenButton, OriginScreenButton, ViewportBarButton } from './button';
Expand All @@ -23,7 +23,7 @@ import { EnableViewportAction, SetViewportZoomAction } from '@axonivy/process-ed
export class ViewportBar extends GLSPAbstractUIExtension implements IActionHandler {
static readonly ID = 'ivy-viewport-bar';

@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: GLSPActionDispatcher;
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: IActionDispatcher;
@inject(TYPES.IToolManager) protected readonly toolManager: IToolManager;
@inject(EditorContextService) protected readonly editorContext: EditorContextService;
@inject(SelectionService) protected selectionService: SelectionService;
Expand Down
7 changes: 4 additions & 3 deletions packages/inscription/src/inscription/inscription-ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import {
Action,
GArgument,
GLSPAbstractUIExtension,
GLSPActionDispatcher,
GModelRoot,
IActionHandler,
ISelectionListener,
SelectAction,
SelectAllAction,
SelectionService,
TYPES,
isNotUndefined,
isOpenable
isOpenable,
type IActionDispatcher
} from '@eclipse-glsp/client';
import { webSocketConnection, type Connection } from '@axonivy/jsonrpc';
import type { MonacoLanguageClient } from 'monaco-languageclient';
Expand All @@ -32,7 +33,7 @@ export class InscriptionUi extends GLSPAbstractUIExtension implements IActionHan
static readonly ID = 'inscription-ui';

@inject(SelectionService) protected readonly selectionService: SelectionService;
@inject(GLSPActionDispatcher) protected readonly actionDispatcher: GLSPActionDispatcher;
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: IActionDispatcher;

private inscriptionElement?: string;
private action?: EnableInscriptionAction;
Expand Down

0 comments on commit e4912f1

Please sign in to comment.