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

Rename ModelSourceChangedAction to SourceModelChangedAction #117

Merged
merged 2 commits into from
Jun 1, 2022
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
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