Skip to content

Commit

Permalink
GLSP-1362: Register GLSPDiagramManagers as open with handler (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
tortmayr committed Jul 8, 2024
1 parent 7cc625c commit c863491
Show file tree
Hide file tree
Showing 9 changed files with 702 additions and 363 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ For details on building the project, please see the [README file of the theia-in
| 1.0.0-theia1.34.0 | >=1.34.0 < 1.39.0 |
| 2.0.0 | >=1.39.0 < 1.45.0 |
| 2.1.x | >=1.39.0 < 1.45.0 |
| 2.1.0-theia1.45.0 | >=1.45.0 < 1.50.0 |
| 2.1.0-theia1.50.0 | >=1.45.0 |
| next | >=1.45.0 |
| 2.1.0-theia1.45.0 | >=1.45.0 < 1.49.0 |
| 2.1.0-theia1.49.0 | >=1.49.0 |
| next | >=1.49.0 |

> Note: For versions <=1.0.0 it is not possible to safely restrict the maximum version of Theia packages. If you encounter build errors related to multiple resolved Theia versions please add a resolutions block to the `package.json` of your project e.g. for `1.0.0-theia1.27.0`:
Expand Down
24 changes: 12 additions & 12 deletions examples/browser-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
},
"dependencies": {
"@eclipse-glsp-examples/workflow-theia": "2.1.0-theia1.45.0",
"@theia/core": "1.45.1",
"@theia/editor": "1.45.1",
"@theia/filesystem": "1.45.1",
"@theia/markers": "1.45.1",
"@theia/messages": "1.45.1",
"@theia/monaco": "1.45.1",
"@theia/navigator": "1.45.1",
"@theia/preferences": "1.45.1",
"@theia/process": "1.45.1",
"@theia/terminal": "1.45.1",
"@theia/workspace": "1.45.1"
"@theia/core": "1.49.1",
"@theia/editor": "1.49.1",
"@theia/filesystem": "1.49.1",
"@theia/markers": "1.49.1",
"@theia/messages": "1.49.1",
"@theia/monaco": "1.49.1",
"@theia/navigator": "1.49.1",
"@theia/preferences": "1.49.1",
"@theia/process": "1.49.1",
"@theia/terminal": "1.49.1",
"@theia/workspace": "1.49.1"
},
"devDependencies": {
"@theia/cli": "1.45.1"
"@theia/cli": "1.49.1"
},
"theia": {
"target": "browser"
Expand Down
5 changes: 3 additions & 2 deletions examples/workflow-theia/src/common/workflow-language.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019-2021 EclipseSource and others.
* Copyright (c) 2019-2024 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -17,7 +17,8 @@ import { GLSPDiagramLanguage } from '@eclipse-glsp/theia-integration/lib/common'

export const WorkflowLanguage: GLSPDiagramLanguage = {
contributionId: 'workflow',
label: 'Workflow Diagram',
label: 'Workflow Editor',
providerName: 'GLSP Diagram',
diagramType: 'workflow-diagram',
fileExtensions: ['.wf'],
iconClass: 'codicon codicon-type-hierarchy-sub'
Expand Down
6 changes: 3 additions & 3 deletions packages/theia-integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ This project is built with `yarn` and is available from npm via [@eclipse-glsp/t
| 1.0.0-theia1.34.0 | >=1.34.0 < 1.39.0 |
| 2.0.0 | >=1.39.0 < 1.45.0 |
| 2.1.x | >=1.39.0 < 1.45.0 |
| 2.1.0-theia1.45.0 | >=1.45.0 < 1.50.0 |
| 2.1.0-theia1.50.0 | >=1.45.0 |
| next | >=1.45.0 |
| 2.1.0-theia1.45.0 | >=1.45.0 < 1.49.0 |
| 2.1.0-theia1.49.0 | >=1.49.0 |
| next | >=1.49.0 |

> Note: For versions <=1.0.0 it is not possible to safely restrict the maximum version of Theia packages. If you encounter build errors related to multiple resolved Theia versions please add a resolutions block to the `package.json` of your project e.g. for `1.0.0-theia1.27.0`:
Expand Down
8 changes: 4 additions & 4 deletions packages/theia-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
"@types/ws": "^8.5.4"
},
"peerDependencies": {
"@theia/core": "^1.45.1",
"@theia/filesystem": "^1.45.1",
"@theia/messages": "^1.45.1",
"@theia/monaco": "^1.45.1"
"@theia/core": "^1.49.0",
"@theia/filesystem": "^1.49.0",
"@theia/messages": "^1.49.0",
"@theia/monaco": "^1.49.0"
},
"publishConfig": {
"access": "public"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ import {
ApplicationShell,
FrontendApplicationContribution,
OpenHandler,
OpenWithHandler,
OpenWithService,
WidgetFactory,
WidgetOpenerOptions,
WidgetOpenHandler
} from '@theia/core/lib/browser';
import URI from '@theia/core/lib/common/uri';
import { inject, injectable, interfaces } from '@theia/core/shared/inversify';
import { inject, injectable, interfaces, postConstruct } from '@theia/core/shared/inversify';
import { EditorManager } from '@theia/editor/lib/browser';
import { DiagramServiceProvider } from '../diagram-service-provider';
import { TheiaOpenerOptionsNavigationService } from '../theia-opener-options-navigation-service';
Expand All @@ -48,7 +50,7 @@ export function registerDiagramManager(
}

@injectable()
export abstract class GLSPDiagramManager extends WidgetOpenHandler<GLSPDiagramWidget> implements WidgetFactory {
export abstract class GLSPDiagramManager extends WidgetOpenHandler<GLSPDiagramWidget> implements WidgetFactory, OpenWithHandler {
@inject(TheiaOpenerOptionsNavigationService)
protected readonly diagramNavigationService: TheiaOpenerOptionsNavigationService;

Expand All @@ -61,6 +63,9 @@ export abstract class GLSPDiagramManager extends WidgetOpenHandler<GLSPDiagramWi
@inject(EditorManager)
protected readonly editorManager: EditorManager;

@inject(OpenWithService)
protected openWithService: OpenWithService;

abstract get fileExtensions(): string[];

abstract get diagramType(): string;
Expand All @@ -69,6 +74,16 @@ export abstract class GLSPDiagramManager extends WidgetOpenHandler<GLSPDiagramWi

protected widgetCount = 0;

protected registerOpenWithHandler = true;

@postConstruct()
protected override init(): void {
super.init();
if (this.registerOpenWithHandler) {
this.openWithService.registerHandler(this);
}
}

override async doOpen(widget: GLSPDiagramWidget, maybeOptions?: WidgetOpenerOptions): Promise<void> {
const widgetWasAttached = widget.isAttached;
const options: WidgetOpenerOptions = {
Expand Down Expand Up @@ -174,6 +189,10 @@ export abstract class GLSPDiagramManager extends WidgetOpenHandler<GLSPDiagramWi
get iconClass(): string {
return codiconCSSString('type-hierarchy-sub');
}

get providerName(): string | undefined {
return undefined;
}
}

export interface GLSPWidgetOpenerOptions extends WidgetOpenerOptions {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (C) 2021-2022 EclipseSource and others.
* Copyright (c) 2021-2024 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -214,13 +214,15 @@ class ConfigurableGLSPDiagramManager extends GLSPDiagramManager {
private _fileExtensions: string[] = [];
private _iconClass = codiconCSSString('type-hierarchy-sub');
private _contributionId: string;
private _providerName?: string;

public doConfigure(diagramLanguage: GLSPDiagramLanguage): void {
this._fileExtensions = diagramLanguage.fileExtensions;
this._diagramType = diagramLanguage.diagramType;
this._label = diagramLanguage.label;
this._iconClass = diagramLanguage.iconClass || this._iconClass;
this._contributionId = diagramLanguage.contributionId;
this._providerName = diagramLanguage.providerName;
}

get fileExtensions(): string[] {
Expand All @@ -242,6 +244,10 @@ class ConfigurableGLSPDiagramManager extends GLSPDiagramManager {
return this._contributionId;
}

override get providerName(): string | undefined {
return this._providerName;
}

override get iconClass(): string {
return this._iconClass;
}
Expand Down
10 changes: 8 additions & 2 deletions packages/theia-integration/src/common/glsp-diagram-language.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2021 EclipseSource and others.
* Copyright (c) 2021-2024 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -27,9 +27,15 @@ export interface GLSPDiagramLanguage {
readonly fileExtensions: string[];
/** Display-label for this language. Is used in UI elements like the editor-widget title */
readonly label: string;
/**
* An optional provider name for this language. If defined, it will be used in supporting UI elements
* e.g. the open-with dialog.
*/
readonly providerName?: string;
/** The icon class that is associated with this language. If undefined, a default icon class will be used */
readonly iconClass?: string;
/** The id of the diagram manager that is responsible for this language. If undefined, a default id derived
/**
* The id of the diagram manager that is responsible for this language. If undefined, a default id derived
* from the diagram type will be used.
*/
readonly diagramManagerId?: string;
Expand Down
Loading

0 comments on commit c863491

Please sign in to comment.