Skip to content

Commit

Permalink
Fix issue with UI extensions (#360)
Browse files Browse the repository at this point in the history
- Use our GLSPAbstractUIExtension instead of AbstractUIExtension
- Fix focus issue with GlspEditLabelUI
  • Loading branch information
martin-fleck-at authored Jun 17, 2024
1 parent d49f704 commit 062e335
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import {
AbstractUIExtension,
Action,
AutoCompleteWidget,
DOMHelper,
EditorContextService,
GLSPAbstractUIExtension,
GLSPActionDispatcher,
GModelRoot,
ILogger,
LabeledAction,
ModelIndexImpl,
Operation,
RequestContextActions,
RequestEditValidationAction,
GModelRoot,
SetContextActions,
SetEditValidationResultAction,
TYPES,
Expand Down Expand Up @@ -85,7 +85,7 @@ export namespace EditTaskOperation {
}

@injectable()
export class TaskEditor extends AbstractUIExtension {
export class TaskEditor extends GLSPAbstractUIExtension {
static readonly ID = 'task-editor';
readonly autoSuggestionSettings = {
noSuggestionsMessage: 'No suggestions available',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@
* 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 { inject } from 'inversify';
import { AbstractUIExtension, Action, LabeledAction, GModelRoot, TYPES } from '@eclipse-glsp/sprotty';
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';

/**
* A reusable base implementation for `UIExtensions` that want to provide autocomplete functionality
* using the {@link AutoCompleteWidget}.
*
*/
export abstract class BaseAutocompletePalette extends AbstractUIExtension {
export abstract class BaseAutocompletePalette extends GLSPAbstractUIExtension {
protected readonly autoSuggestionSettings = {
noSuggestionsMessage: 'No suggestions available',
suggestionsClass: 'command-palette-suggestions',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { Action, GModelRoot, IActionHandler, ICommand, matchesKeystroke } from '@eclipse-glsp/sprotty';
import { injectable } from 'inversify';
import { groupBy } from 'lodash';
import { AbstractUIExtension, Action, IActionHandler, ICommand, matchesKeystroke, GModelRoot } from '@eclipse-glsp/sprotty';
import { GLSPAbstractUIExtension } from '../../../base/ui-extension/ui-extension';

export interface AccessibleKeyShortcutProvider {
registerShortcutKey(): void;
Expand Down Expand Up @@ -48,7 +49,7 @@ export namespace SetAccessibleKeyShortcutAction {
}

@injectable()
export class KeyShortcutUIExtension extends AbstractUIExtension implements IActionHandler {
export class KeyShortcutUIExtension extends GLSPAbstractUIExtension implements IActionHandler {
static readonly ID = 'key-shortcut';
protected container: HTMLDivElement;
protected shortcutsContainer: HTMLDivElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@
********************************************************************************/
import '../../../../css/keyboard.css';

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

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

protected triggerActions: Action[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,19 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Action, GModelRoot, IActionDispatcher, IActionHandler, TYPES, TriggerNodeCreationAction } from '@eclipse-glsp/sprotty';
import { inject, injectable } from 'inversify';
import {
AbstractUIExtension,
IActionDispatcher,
IActionHandler,
GModelRoot,
TYPES,
Action,
TriggerNodeCreationAction
} from '@eclipse-glsp/sprotty';
import { EditorContextService } from '../../../base/editor-context-service';
import { CursorCSS } from '../../../base/feedback/css-feedback';
import { GLSPAbstractUIExtension } from '../../../base/ui-extension/ui-extension';
import { KeyboardGridCellSelectedAction } from '../keyboard-grid/action';
import { SetKeyboardPointerRenderPositionAction } from './actions';
import { KeyboardPointerMetadata } from './constants';
import { KeyboardPointerKeyboardListener } from './keyboard-pointer-listener';
import { KeyboardPointerPosition } from './keyboard-pointer-position';
import { KeyboardGridCellSelectedAction } from '../keyboard-grid/action';
import { EditorContextService } from '../../../base/editor-context-service';
import { CursorCSS } from '../../../base/feedback/css-feedback';

@injectable()
export class KeyboardPointer extends AbstractUIExtension implements IActionHandler {
export class KeyboardPointer extends GLSPAbstractUIExtension implements IActionHandler {
protected _triggerAction: TriggerNodeCreationAction = {
elementTypeId: 'task:automated',
kind: 'triggerNodeCreation'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { injectable, inject } from 'inversify';
import { Action, AbstractUIExtension, IActionHandler, ICommand, TYPES } from '@eclipse-glsp/sprotty';
import { IDiagramStartup } from '../../../base/model/diagram-loader';
import { Action, IActionHandler, ICommand, TYPES } from '@eclipse-glsp/sprotty';
import { inject, injectable } from 'inversify';
import { GLSPActionDispatcher } from '../../../base/action-dispatcher';
import { EditorContextService } from '../../../base/editor-context-service';
import { IDiagramStartup } from '../../../base/model/diagram-loader';
import { GLSPAbstractUIExtension } from '../../../base/ui-extension/ui-extension';
import { HideToastAction, ShowToastMessageAction, ToastOptions } from './toast-handler';

/**
* This extension is used to create customized user notifications as toast messages.
*/
@injectable()
export class Toast extends AbstractUIExtension implements IActionHandler, IDiagramStartup {
export class Toast extends GLSPAbstractUIExtension implements IActionHandler, IDiagramStartup {
static readonly ID = 'toast';
protected messages: { [key: symbol]: ToastOptions } = {};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class GlspEditLabelUI extends EditLabelUI {
protected override setContainerVisible(visible: boolean): void {
if (visible) {
this.containerElement?.classList.remove(CSS_HIDDEN_EXTENSION_CLASS);
this.editControl.focus();
} else {
this.containerElement?.classList.add(CSS_HIDDEN_EXTENSION_CLASS);
}
Expand Down
5 changes: 3 additions & 2 deletions packages/client/src/features/status/status-overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { IActionHandler, StatusAction, codiconCSSClasses } from '@eclipse-glsp/sprotty';
import { inject, injectable } from 'inversify';
import { AbstractUIExtension, IActionHandler, StatusAction, codiconCSSClasses } from '@eclipse-glsp/sprotty';
import { GLSPActionDispatcher } from '../../base/action-dispatcher';
import { EditorContextService } from '../../base/editor-context-service';
import { IDiagramStartup } from '../../base/model/diagram-loader';
import { GLSPAbstractUIExtension } from '../../base/ui-extension/ui-extension';

/**
* A reusable status overlay for rendering (icon + message) and handling of {@link StatusAction}'s.
*/
@injectable()
export class StatusOverlay extends AbstractUIExtension implements IActionHandler, IDiagramStartup {
export class StatusOverlay extends GLSPAbstractUIExtension implements IActionHandler, IDiagramStartup {
static readonly ID = 'glsp.server.status.overlay';

@inject(GLSPActionDispatcher)
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/features/tool-palette/tool-palette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import {
AbstractUIExtension,
Action,
GModelRoot,
IActionHandler,
Expand All @@ -37,6 +36,7 @@ import { EditorContextService, IEditModeListener } from '../../base/editor-conte
import { FocusTracker } from '../../base/focus/focus-tracker';
import { IDiagramStartup } from '../../base/model/diagram-loader';
import { EnableDefaultToolsAction, EnableToolsAction } from '../../base/tool-manager/tool';
import { GLSPAbstractUIExtension } from '../../base/ui-extension/ui-extension';
import { DebugManager } from '../debug/debug-manager';
import { GridManager } from '../grid/grid-manager';
import { MouseDeleteTool } from '../tools/deletion/delete-tool';
Expand Down Expand Up @@ -65,7 +65,7 @@ export namespace EnableToolPaletteAction {
}
}
@injectable()
export class ToolPalette extends AbstractUIExtension implements IActionHandler, IEditModeListener, IDiagramStartup {
export class ToolPalette extends GLSPAbstractUIExtension implements IActionHandler, IEditModeListener, IDiagramStartup {
static readonly ID = 'tool-palette';

@inject(GLSPActionDispatcher)
Expand Down

0 comments on commit 062e335

Please sign in to comment.