Skip to content

Commit

Permalink
Rename ModelSourceChangedAction to SourceModelChangedAction (#117)
Browse files Browse the repository at this point in the history
* Rename `ModelSourceChangedAction`

... to `SourceModelChangedAction`. This is to be consistent with the
term source model that we now use to refer to the underlying model from
which the GModel is created.

eclipse-glsp/glsp#655

Change-Id: Ica2359681f2edb2523aad9d2869d265ad241e381

* Consume latest glsp-client next version

Co-authored-by: Tobias Ortmayr <[email protected]>
  • Loading branch information
planger and tortmayr authored Jun 1, 2022
1 parent e1dad52 commit 0374c00
Show file tree
Hide file tree
Showing 5 changed files with 442 additions and 440 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Breaking Changes

- [theia] Updated Theia dependencies to >=1.22.0. Due to an API break Theia versions <= 1.22.0 are no longer supported. [#105](https://github.com/eclipse-glsp/glsp-theia-integration/pull/105)
- [protocol] Adapt to renamed `ModelSourceChangedAction` and handler [#117](https://github.com/eclipse-glsp/glsp-theia-integration/pull/117)

## [v0.9.0- 09/12/2021](https://github.com/eclipse-glsp/glsp-theia-integration/releases/tag/v0.9.0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { configureActionHandler, ExternalModelSourceChangedHandler, NavigateToExternalTargetAction, TYPES } from '@eclipse-glsp/client';
import { configureActionHandler, ExternalSourceModelChangedHandler, NavigateToExternalTargetAction, TYPES } from '@eclipse-glsp/client';
import { CommandService, SelectionService } from '@theia/core';
import { OpenerService } from '@theia/core/lib/browser';
import { Container, inject, injectable } from '@theia/core/shared/inversify';
import { DiagramConfiguration, TheiaContextMenuService, TheiaDiagramServer } from 'sprotty-theia';
import { TheiaModelSourceChangedHandler } from '../theia-model-source-changed-handler';
import { TheiaSourceModelChangedHandler } from '../theia-model-source-changed-handler';
import { TheiaNavigateToExternalTargetHandler } from '../theia-navigate-to-external-target-handler';
import { connectTheiaContextMenuService, TheiaContextMenuServiceFactory } from './theia-context-menu-service';
import { TheiaGLSPConnector, TheiaGLSPConnectorRegistry } from './theia-glsp-connector';
Expand All @@ -30,7 +30,7 @@ export abstract class GLSPDiagramConfiguration implements DiagramConfiguration {
@inject(SelectionService) protected selectionService: SelectionService;
@inject(OpenerService) protected openerService: OpenerService;
@inject(CommandService) protected readonly commandService: CommandService;
@inject(TheiaModelSourceChangedHandler) protected modelSourceChangedHandler: TheiaModelSourceChangedHandler;
@inject(TheiaSourceModelChangedHandler) protected sourceModelChangedHandler: TheiaSourceModelChangedHandler;
@inject(TheiaContextMenuServiceFactory) protected readonly contextMenuServiceFactory: () => TheiaContextMenuService;
@inject(TheiaMarkerManagerFactory) protected readonly theiaMarkerManager: () => TheiaMarkerManager;
@inject(TheiaGLSPConnectorRegistry) protected readonly connectorRegistry: TheiaGLSPConnectorRegistry;
Expand All @@ -52,7 +52,7 @@ export abstract class GLSPDiagramConfiguration implements DiagramConfiguration {
container.bind(SelectionService).toConstantValue(this.selectionService);
container.bind(OpenerService).toConstantValue(this.openerService);
container.bind(CommandService).toConstantValue(this.commandService);
container.bind(ExternalModelSourceChangedHandler).toConstantValue(this.modelSourceChangedHandler);
container.bind(ExternalSourceModelChangedHandler).toConstantValue(this.sourceModelChangedHandler);

connectTheiaContextMenuService(container, this.contextMenuServiceFactory);
connectTheiaMarkerManager(container, this.theiaMarkerManager, this.diagramType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { FrontendApplicationContribution, WebSocketConnectionProvider } from '@t
import { ContainerModule, interfaces } from '@theia/core/shared/inversify';
import { NotificationManager } from '@theia/messages/lib/browser/notifications-manager';
import { TheiaContextMenuService } from 'sprotty-theia/lib/sprotty/theia-sprotty-context-menu-service';

import { GLSPContribution } from '../common';
import { GLSPDiagramContextKeyService } from './diagram/glsp-diagram-context-key-service';
import { TheiaGLSPConnectorProvider } from './diagram/glsp-diagram-manager';
Expand All @@ -29,7 +28,7 @@ import { TheiaMarkerManager, TheiaMarkerManagerFactory } from './diagram/theia-m
import { GLSPClientContribution } from './glsp-client-contribution';
import { GLSPClientProvider, GLSPClientProviderImpl } from './glsp-client-provider';
import { GLSPFrontendContribution } from './glsp-frontend-contribution';
import { TheiaModelSourceChangedHandler } from './theia-model-source-changed-handler';
import { TheiaSourceModelChangedHandler } from './theia-model-source-changed-handler';
import { TheiaOpenerOptionsNavigationService } from './theia-opener-options-navigation-service';

export default new ContainerModule((bind, unbind, isBound, rebind) => {
Expand All @@ -53,7 +52,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {

bind(GLSPDiagramContextKeyService).toSelf().inSingletonScope();
bind(TheiaOpenerOptionsNavigationService).toSelf().inSingletonScope();
bind(TheiaModelSourceChangedHandler).toSelf().inSingletonScope();
bind(TheiaSourceModelChangedHandler).toSelf().inSingletonScope();

bind(TheiaContextMenuServiceFactory).toFactory(context => () => {
const container = context.container.createChild();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,27 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Action, ExternalModelSourceChangedHandler, ViewerOptions } from '@eclipse-glsp/client';
import { Action, ExternalSourceModelChangedHandler, ViewerOptions } from '@eclipse-glsp/client';
import { ApplicationShell, ConfirmDialog, Widget } from '@theia/core/lib/browser';
import { inject, injectable } from '@theia/core/shared/inversify';

import { getDiagramWidget } from './diagram/glsp-diagram-widget';

@injectable()
export class TheiaModelSourceChangedHandler extends ExternalModelSourceChangedHandler {
export class TheiaSourceModelChangedHandler extends ExternalSourceModelChangedHandler {
@inject(ApplicationShell) protected readonly shell: ApplicationShell;

async notifyModelSourceChange(modelSourceName: string, options: ViewerOptions): Promise<Action[]> {
async notifySourceModelChange(sourceModelName: string, options: ViewerOptions): Promise<Action[]> {
const element = document.getElementById(options.baseDiv);
if (element) {
const widget = this.shell.findWidgetForElement(element);
if (widget) {
return this.notifyModelSourceChangedWithWidget(widget, modelSourceName);
return this.notifySourceModelChangedWithWidget(widget, sourceModelName);
}
}
return [];
}

protected async notifyModelSourceChangedWithWidget(widget: Widget, modelSourceName: string): Promise<Action[]> {
protected async notifySourceModelChangedWithWidget(widget: Widget, sourceModelName: string): Promise<Action[]> {
const diagramWidget = getDiagramWidget(widget);
if (!diagramWidget) {
return [];
Expand All @@ -44,7 +43,7 @@ export class TheiaModelSourceChangedHandler extends ExternalModelSourceChangedHa
return [];
}
await this.shell.activateWidget(widget.id);
const reload = await this.showDialog(widget.title.label, modelSourceName);
const reload = await this.showDialog(widget.title.label, sourceModelName);
if (reload === true) {
await diagramWidget.reloadModel();
}
Expand All @@ -55,10 +54,10 @@ export class TheiaModelSourceChangedHandler extends ExternalModelSourceChangedHa
return false;
}

protected showDialog(widgetTitle: string, modelSourceName: string): Promise<boolean | undefined> {
protected showDialog(widgetTitle: string, sourceModelName: string): Promise<boolean | undefined> {
const dialog = new ConfirmDialog({
title: `Source of editor '${widgetTitle}' changed`,
msg: `The source '${modelSourceName}' changed. Do you want to omit
msg: `The source model '${sourceModelName}' changed. Do you want to omit
local changes and reload the editor or continue editing and ignore the changes?`,
cancel: 'Continue editing',
ok: 'Reload editor',
Expand Down
Loading

0 comments on commit 0374c00

Please sign in to comment.