Skip to content

Commit

Permalink
GLSP-1416: Align ActionDispatcher API
Browse files Browse the repository at this point in the history
- Rename `action-override` module of @eclipse-glsp/sprotty to `api-override` which  a better fit.
- Add additional API methods of the `GLSPActionDispatcher` directly to the `IActionDispatcher` interface and update related code for consistent usage of the interface. Export new `IActionDispatcher` interface via api-override
- Also add API override for `IVNodePostProcessor`

Also:
- Adjust directs imports of `matchesKeystroke` and `toArray` from sprotty.  Import from @eclipse/glsp-sprotty instead

Fixes eclipse-glsp/glsp#1416
  • Loading branch information
tortmayr committed Oct 24, 2024
1 parent 6953835 commit 04d5de1
Show file tree
Hide file tree
Showing 42 changed files with 268 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
DOMHelper,
EditorContextService,
GLSPAbstractUIExtension,
GLSPActionDispatcher,
GModelRoot,
IActionDispatcher,
ILogger,
LabeledAction,
ModelIndexImpl,
Expand Down Expand Up @@ -95,7 +95,7 @@ export class TaskEditor extends GLSPAbstractUIExtension {
};

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

@inject(EditorContextService)
protected editorContextService: EditorContextService;
Expand Down
13 changes: 11 additions & 2 deletions packages/client/src/base/action-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,24 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Action, ActionDispatcher, EMPTY_ROOT, GModelRoot, RequestAction, ResponseAction, SetModelAction } from '@eclipse-glsp/sprotty';
import {
Action,
ActionDispatcher,
EMPTY_ROOT,
GModelRoot,
IActionDispatcher,
RequestAction,
ResponseAction,
SetModelAction
} from '@eclipse-glsp/sprotty';
import { inject, injectable } from 'inversify';
import { GLSPActionHandlerRegistry } from './action-handler-registry';
import { IGModelRootListener } from './editor-context-service';
import { OptionalAction } from './model/glsp-model-source';
import { ModelInitializationConstraint } from './model/model-initialization-constraint';

@injectable()
export class GLSPActionDispatcher extends ActionDispatcher implements IGModelRootListener {
export class GLSPActionDispatcher extends ActionDispatcher implements IGModelRootListener, IActionDispatcher {
protected readonly timeouts: Map<string, NodeJS.Timeout> = new Map();
protected initializedConstraint = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { Action, GModelRoot, LabeledAction, TYPES } from '@eclipse-glsp/sprotty';
import { Action, GModelRoot, IActionDispatcher, LabeledAction, TYPES } from '@eclipse-glsp/sprotty';
import { inject } from 'inversify';
import '../../../css/autocomplete-palette.css';
import { GLSPActionDispatcher } from '../action-dispatcher';
import { GLSPAbstractUIExtension } from '../ui-extension/ui-extension';
import { AutoCompleteWidget, CloseReason, toActionArray } from './auto-complete-widget';

Expand All @@ -38,7 +37,7 @@ export abstract class BaseAutocompletePalette extends GLSPAbstractUIExtension {
protected autocompleteWidget: AutoCompleteWidget;

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

containerClass(): string {
return 'autocomplete-palette';
Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/base/editor-context-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
Event,
GModelElement,
GModelRoot,
IActionDispatcher,
IActionHandler,
LazyInjector,
MaybePromise,
Expand All @@ -36,7 +37,6 @@ import {
ValueChange
} from '@eclipse-glsp/sprotty';
import { inject, injectable, postConstruct, preDestroy } from 'inversify';
import { GLSPActionDispatcher } from './action-dispatcher';
import { FocusChange, FocusTracker } from './focus/focus-tracker';
import { IDiagramOptions, IDiagramStartup } from './model/diagram-loader';
import { SelectionChange, SelectionService } from './selection-service';
Expand Down Expand Up @@ -89,8 +89,8 @@ export class EditorContextService implements IActionHandler, Disposable, IDiagra
@inject(TYPES.IDiagramOptions)
protected diagramOptions: IDiagramOptions;

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

@inject(FocusTracker)
protected focusTracker: FocusTracker;
Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/base/model/diagram-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
Args,
EMPTY_ROOT,
GLSPClient,
IActionDispatcher,
InitializeParameters,
LazyInjector,
MaybePromise,
Expand All @@ -30,7 +31,6 @@ import {
hasNumberProp
} from '@eclipse-glsp/sprotty';
import { inject, injectable } from 'inversify';
import { GLSPActionDispatcher } from '../action-dispatcher';
import { Ranked } from '../ranked';
import { GLSPModelSource } from './glsp-model-source';
import { ModelInitializationConstraint } from './model-initialization-constraint';
Expand Down Expand Up @@ -148,8 +148,8 @@ export class DiagramLoader {
@inject(TYPES.IDiagramOptions)
protected options: IDiagramOptions;

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

@inject(GLSPModelSource)
protected modelSource: GLSPModelSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { injectable } from 'inversify';
import {
Action,
codiconCSSString,
isConnectable,
CreateEdgeOperation,
GModelElement,
GModelRoot,
IActionHandler,
isConnectable,
LabeledAction,
name,
SetUIExtensionVisibilityAction,
IActionHandler,
Action,
CreateEdgeOperation,
toArray,
TriggerEdgeCreationAction
} from '@eclipse-glsp/sprotty';
import { EnableDefaultToolsAction } from '../../../base/tool-manager/tool';
import { toArray } from 'sprotty/lib/utils/iterable';
import { EdgeAutocompleteContext } from './edge-autocomplete-context';
import { SearchAutocompletePalette } from '../search/search-palette';
import { SetEdgeTargetSelectionAction } from './action';
import { injectable } from 'inversify';
import { CloseReason, toActionArray } from '../../../base/auto-complete/auto-complete-widget';
import { AutocompleteSuggestion, IAutocompleteSuggestionProvider } from '../../../base/auto-complete/autocomplete-suggestion-providers';
import { EnableDefaultToolsAction } from '../../../base/tool-manager/tool';
import { GEdge } from '../../../model';
import { SearchAutocompletePalette } from '../search/search-palette';
import { SetEdgeTargetSelectionAction } from './action';
import { EdgeAutocompleteContext } from './edge-autocomplete-context';

export namespace EdgeAutocompletePaletteMetadata {
export const ID = 'edge-autocomplete-palette';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Action, GModelElement, KeyListener, KeyTool, matchesKeystroke, SetUIExtensionVisibilityAction } from '@eclipse-glsp/sprotty';
import { inject, injectable } from 'inversify';
import { KeyTool, KeyListener, SetUIExtensionVisibilityAction, GModelElement, Action } from '@eclipse-glsp/sprotty';
import { Tool } from '../../../base/tool-manager/tool';
import { matchesKeystroke } from 'sprotty/lib/utils/keyboard';
import { EdgeAutocompletePaletteMetadata } from './edge-autocomplete-palette';

@injectable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
Action,
GModelElement,
GModelRoot,
IActionDispatcher,
KeyListener,
KeyTool,
SelectAction,
Expand All @@ -26,13 +27,13 @@ import {
findParentByFeature,
isBoundsAware,
isSelectable,
isSelected
isSelected,
matchesKeystroke,
toArray
} from '@eclipse-glsp/sprotty';
import { inject, injectable } from 'inversify';
import { toArray } from 'sprotty/lib/utils/iterable';
import { matchesKeystroke } from 'sprotty/lib/utils/keyboard';
import { GLSPActionDispatcher } from '../../../base/action-dispatcher';
import { EnableDefaultToolsAction, EnableToolsAction, Tool } from '../../../base/tool-manager/tool';
import { GEdge } from '../../../model';
import { SelectableBoundsAware } from '../../../utils/gmodel-util';
import { RepositionAction } from '../../viewport/reposition';
import { SetAccessibleKeyShortcutAction } from '../key-shortcut/accessible-key-shortcut';
Expand All @@ -41,7 +42,6 @@ import { SearchAutocompletePaletteTool } from '../search/search-tool';
import * as messages from '../toast/messages.json';
import { ShowToastMessageAction } from '../toast/toast-handler';
import { ElementNavigator } from './element-navigator';
import { GEdge } from '../../../model';

@injectable()
export class ElementNavigatorTool implements Tool {
Expand All @@ -53,7 +53,7 @@ export class ElementNavigatorTool implements Tool {
@inject(KeyTool) protected readonly keytool: KeyTool;
@inject(TYPES.IElementNavigator) readonly elementNavigator: ElementNavigator;
@inject(TYPES.ILocalElementNavigator) readonly localElementNavigator: ElementNavigator;
@inject(TYPES.IActionDispatcher) readonly actionDispatcher: GLSPActionDispatcher;
@inject(TYPES.IActionDispatcher) readonly actionDispatcher: IActionDispatcher;

get id(): string {
return ElementNavigatorTool.ID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { EdgeRouterRegistry, findParentByFeature, GModelElement, GModelRoot, Point } from '@eclipse-glsp/sprotty';
import { EdgeRouterRegistry, findParentByFeature, GModelElement, GModelRoot, Point, toArray } from '@eclipse-glsp/sprotty';
import { inject, injectable, optional } from 'inversify';
import { toArray } from 'sprotty/lib/utils/iterable';
import { GEdge } from '../../../model';
import { calcElementAndRoute, isRoutable, isSelectableAndBoundsAware, SelectableBoundsAware } from '../../../utils/gmodel-util';
import { ElementNavigator } from './element-navigator';
import { GEdge } from '../../../model';

@injectable()
export class LeftToRightTopToBottomElementNavigator implements ElementNavigator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { EdgeRouterRegistry, GConnectableElement, GModelElement, GModelRoot, TYPES } from '@eclipse-glsp/sprotty';
import { EdgeRouterRegistry, GConnectableElement, GModelElement, GModelRoot, IActionDispatcher, TYPES } from '@eclipse-glsp/sprotty';
import { inject, injectable, optional } from 'inversify';
import { GLSPActionDispatcher } from '../../../base/action-dispatcher';
import { applyCssClasses, deleteCssClasses } from '../../../base/feedback/css-feedback';
import { GEdge } from '../../../model';
import { BoundsAwareModelElement, SelectableBoundsAware } from '../../../utils/gmodel-util';
Expand All @@ -25,7 +24,7 @@ import { ElementNavigator } from './element-navigator';
export class LocalElementNavigator implements ElementNavigator {
navigableElementCSS = 'navigable-element';
@inject(EdgeRouterRegistry) @optional() readonly edgeRouterRegistry?: EdgeRouterRegistry;
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: GLSPActionDispatcher;
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: IActionDispatcher;

previous(
root: Readonly<GModelRoot>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,26 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import {
Bounds,
GChildElement,
GModelElement,
GModelRoot,
GNode,
IActionDispatcher,
Point,
TYPES,
isBoundsAware,
isSelectable,
toArray
} from '@eclipse-glsp/sprotty';
import { inject, injectable } from 'inversify';
import { toArray } from 'sprotty/lib/utils/iterable';
import { Bounds, GChildElement, Point, GModelElement, GModelRoot, GNode, TYPES, isBoundsAware, isSelectable } from '@eclipse-glsp/sprotty';
import { GLSPActionDispatcher } from '../../../base/action-dispatcher';
import { SelectableBoundsAware } from '../../../utils/gmodel-util';
import { ElementNavigator } from './element-navigator';

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

previous(
root: Readonly<GModelRoot>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { IActionDispatcher, TYPES, ViewerOptions } from '@eclipse-glsp/sprotty';
import { inject, injectable } from 'inversify';
import { TYPES, ViewerOptions } from '@eclipse-glsp/sprotty';
import { GLSPActionDispatcher } from '../../../base/action-dispatcher';
import { Tool } from '../../../base/tool-manager/tool';
import * as messages from '../toast/messages.json';
import { ShowToastMessageAction } from '../toast/toast-handler';
Expand All @@ -27,7 +26,7 @@ export class FocusTrackerTool implements Tool {

isEditTool = false;
@inject(TYPES.IActionDispatcher)
protected actionDispatcher: GLSPActionDispatcher;
protected actionDispatcher: IActionDispatcher;
@inject(TYPES.ViewerOptions)
protected readonly viewerOptions: ViewerOptions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Action, IActionDispatcher, matchesKeystroke, SetUIExtensionVisibilityAction, TYPES } from '@eclipse-glsp/sprotty';
import { inject, injectable } from 'inversify';
import { SetUIExtensionVisibilityAction, Action } from '@eclipse-glsp/sprotty';
import { Tool } from '../../base/tool-manager/tool';
import { matchesKeystroke } from 'sprotty/lib/utils/keyboard';
import { KeyboardGridMetadata, KeyboardNodeGridMetadata } from '../accessibility/keyboard-grid/constants';
import { ToolPalette } from '../tool-palette/tool-palette';
import { FocusDomAction } from './actions';
import { KeyboardGridMetadata, KeyboardNodeGridMetadata } from '../accessibility/keyboard-grid/constants';
import { KeyboardPointerMetadata } from './keyboard-pointer/constants';
import { AccessibleKeyShortcutProvider, SetAccessibleKeyShortcutAction } from './key-shortcut/accessible-key-shortcut';
import { GLSPActionDispatcher } from '../../base/action-dispatcher';
import { KeyboardPointerMetadata } from './keyboard-pointer/constants';
import { KeyboardToolPalette } from './keyboard-tool-palette/keyboard-tool-palette';

@injectable()
Expand All @@ -32,8 +30,8 @@ export class GlobalKeyListenerTool implements Tool, AccessibleKeyShortcutProvide
isEditTool = false;
protected alreadyRegistered = false;

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

get id(): string {
return GlobalKeyListenerTool.ID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@ import '../../../../css/keyboard.css';

import {
Action,
ActionDispatcher,
GModelRoot,
IActionDispatcher,
IActionHandler,
ICommand,
KeyCode,
matchesKeystroke,
Point,
SetUIExtensionVisibilityAction,
TYPES
} from '@eclipse-glsp/sprotty';
import { inject, injectable } from 'inversify';
import { KeyCode, matchesKeystroke } from 'sprotty/lib/utils/keyboard';
import { GLSPAbstractUIExtension } from '../../../base/ui-extension/ui-extension';
import { EnableKeyboardGridAction, KeyboardGridCellSelectedAction, KeyboardGridKeyboardEventAction } from './action';
import { KeyboardGridMetadata } from './constants';

@injectable()
export class KeyboardGrid extends GLSPAbstractUIExtension implements IActionHandler {
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: ActionDispatcher;
@inject(TYPES.IActionDispatcher) protected readonly actionDispatcher: IActionDispatcher;

protected triggerActions: Action[] = [];
protected originId: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
********************************************************************************/
import '../../../../css/keyboard.css';

import { Action, ICommand, matchesKeystroke, SetUIExtensionVisibilityAction } from '@eclipse-glsp/sprotty';
import { inject, injectable } from 'inversify';
import { ICommand, SetUIExtensionVisibilityAction, Action } from '@eclipse-glsp/sprotty';
import { matchesKeystroke } from 'sprotty/lib/utils/keyboard';
import { KeyboardPointer } from '../keyboard-pointer/keyboard-pointer';
import { KeyboardPointerMetadata } from '../keyboard-pointer/constants';
import { GridSearchPaletteMetadata } from './keyboard-grid-search-palette';
import { KeyboardGrid } from './keyboard-grid';
import { KeyboardPointer } from '../keyboard-pointer/keyboard-pointer';
import { KeyboardNodeGridMetadata } from './constants';
import { KeyboardGrid } from './keyboard-grid';
import { GridSearchPaletteMetadata } from './keyboard-grid-search-palette';

@injectable()
export class KeyboardNodeGrid extends KeyboardGrid {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { IActionDispatcher, SetUIExtensionVisibilityAction, CreateNodeOperation } from '@eclipse-glsp/sprotty';
import { matchesKeystroke } from 'sprotty/lib/utils/keyboard';
import { CreateNodeOperation, IActionDispatcher, matchesKeystroke, SetUIExtensionVisibilityAction } from '@eclipse-glsp/sprotty';
import { CursorCSS } from '../../../base/feedback/css-feedback';
import { EnableDefaultToolsAction } from '../../../base/tool-manager/tool';
import { KeyboardNodeGridMetadata } from '../keyboard-grid/constants';
import { KeyboardPointerMetadata } from './constants';
import { KeyboardPointer } from './keyboard-pointer';
import { KeyboardPointerPosition } from './keyboard-pointer-position';
import { EnableDefaultToolsAction } from '../../../base/tool-manager/tool';
import { CursorCSS } from '../../../base/feedback/css-feedback';

/**
* Keyboard listener for the pointer with the necessary logic to handle keyboard events
Expand Down
Loading

0 comments on commit 04d5de1

Please sign in to comment.