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

#258 Refactor theia integration code base #84

Merged
merged 2 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019 EclipseSource and others.
* Copyright (c) 2019-2021 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 @@ -16,17 +16,15 @@
import 'sprotty-theia/css/theia-sprotty.css';

import { createWorkflowDiagramContainer } from '@eclipse-glsp-examples/workflow-glsp/lib';
import {
GLSPTheiaDiagramConfiguration
} from '@eclipse-glsp/theia-integration/lib/browser/diagram/glsp-theia-diagram-configuration';
import { GLSPDiagramConfiguration } from '@eclipse-glsp/theia-integration';
import { Container, injectable } from '@theia/core/shared/inversify';

import { WorkflowLanguage } from '../../common/workflow-language';
import { WorkflowDiagramServer } from './workflow-diagram-server';

@injectable()
export class WorkflowDiagramConfiguration extends GLSPTheiaDiagramConfiguration {
diagramType: string = WorkflowLanguage.DiagramType;
export class WorkflowDiagramConfiguration extends GLSPDiagramConfiguration {
diagramType: string = WorkflowLanguage.diagramType;

doCreateContainer(widgetId: string): Container {
const container = createWorkflowDiagramContainer(widgetId);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2020 EclipseSource and others.
* Copyright (c) 2020-2021 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 @@ -14,7 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { EditMode } from '@eclipse-glsp/client';
import { GLSPWidgetOpenerOptions } from '@eclipse-glsp/theia-integration/lib/browser';
import { GLSPWidgetOpenerOptions } from '@eclipse-glsp/theia-integration';
import {
Command,
CommandContribution,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2020 EclipseSource and others.
* Copyright (c) 2020-2021 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 @@ -15,7 +15,7 @@
********************************************************************************/
import { ApplyTaskEditOperation } from '@eclipse-glsp-examples/workflow-glsp/lib/direct-task-editing/direct-task-editor';
import { ActionHandlerRegistry } from '@eclipse-glsp/client';
import { GLSPTheiaDiagramServer } from '@eclipse-glsp/theia-integration/lib/browser';
import { GLSPTheiaDiagramServer } from '@eclipse-glsp/theia-integration';
import { injectable } from '@theia/core/shared/inversify';

@injectable()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2020 EclipseSource and others.
* Copyright (c) 2020-2021 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 @@ -13,7 +13,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { GLSPDiagramWidget } from '@eclipse-glsp/theia-integration/lib/browser';
import { GLSPDiagramWidget } from '@eclipse-glsp/theia-integration';
import { ApplicationShell, KeybindingContext, KeybindingContribution, KeybindingRegistry } from '@theia/core/lib/browser';
import { inject, injectable } from '@theia/core/shared/inversify';

Expand All @@ -27,7 +27,7 @@ export class WorkflowDiagramKeybindingContext implements KeybindingContext {
@inject(ApplicationShell) protected readonly shell: ApplicationShell;
isEnabled(): boolean {
return this.shell.activeWidget instanceof GLSPDiagramWidget
&& this.shell.activeWidget.diagramType === WorkflowLanguage.DiagramType;
&& this.shell.activeWidget.diagramType === WorkflowLanguage.diagramType;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2020 EclipseSource and others.
* Copyright (c) 2020-2021 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 @@ -15,7 +15,7 @@
********************************************************************************/
import { isTaskNode } from '@eclipse-glsp-examples/workflow-glsp/lib/model';
import { NavigateAction } from '@eclipse-glsp/client';
import { GLSPCommandHandler, GLSPContextMenu } from '@eclipse-glsp/theia-integration/lib/browser';
import { GLSPCommandHandler, GLSPContextMenu } from '@eclipse-glsp/theia-integration';
import { CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry } from '@theia/core';
import { ApplicationShell } from '@theia/core/lib/browser';
import { inject, injectable } from '@theia/core/shared/inversify';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2020 EclipseSource and others.
* Copyright (c) 2020-2021 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 @@ -16,7 +16,7 @@
import { TaskEditor } from '@eclipse-glsp-examples/workflow-glsp/lib/direct-task-editing/direct-task-editor';
import { isTaskNode } from '@eclipse-glsp-examples/workflow-glsp/lib/model';
import { SetUIExtensionVisibilityAction } from '@eclipse-glsp/client';
import { GLSPCommandHandler, GLSPContextMenu } from '@eclipse-glsp/theia-integration/lib/browser';
import { GLSPCommandHandler, GLSPContextMenu } from '@eclipse-glsp/theia-integration';
import { CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry } from '@theia/core';
import { ApplicationShell } from '@theia/core/lib/browser';
import { inject, injectable } from '@theia/core/shared/inversify';
Expand Down

This file was deleted.

65 changes: 29 additions & 36 deletions examples/workflow-theia/src/browser/workflow-frontend-module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019-2020 EclipseSource and others.
* Copyright (c) 2019-2021 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 @@ -13,22 +13,14 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import {
GLSPClientContribution,
registerCopyPasteContextMenu,
registerDiagramLayoutCommands,
registerDiagramManager,
registerMarkerNavigationCommands
} from '@eclipse-glsp/theia-integration/lib/browser';
import { ContainerContext, GLSPTheiaFrontendModule } from '@eclipse-glsp/theia-integration';
import { CommandContribution, MenuContribution } from '@theia/core';
import { KeybindingContext, KeybindingContribution } from '@theia/core/lib/browser';
import { ContainerModule, interfaces } from '@theia/core/shared/inversify';
import { DiagramConfiguration } from 'sprotty-theia';

import { WorkflowLanguage } from '../common/workflow-language';
import { WorkflowDiagramConfiguration } from './diagram/workflow-diagram-configuration';
import { WorkflowDiagramManager } from './diagram/workflow-diagram-manager';
import { WorkflowDiagramReadonlyViewContribution } from './diagram/workflow-diagram-readonly-view';
import { WorkflowGLSPDiagramClient } from './diagram/workflow-glsp-diagram-client';
import {
WorkflowDiagramKeybindingContext,
WorkflowKeybindingContribution
Expand All @@ -42,33 +34,34 @@ import {
WorkflowTaskEditMenuContribution
} from './diagram/workflow-task-editing-context-menu';
import { ExampleNavigationCommandContribution } from './external-navigation-example/external-navigation-example';
import { WorkflowGLSPClientContribution } from './language/workflow-glsp-client-contribution';

export default new ContainerModule((bind: interfaces.Bind) => {
bind(WorkflowGLSPClientContribution).toSelf().inSingletonScope();
bind(GLSPClientContribution).toService(WorkflowGLSPClientContribution);
bind(DiagramConfiguration).to(WorkflowDiagramConfiguration).inSingletonScope();
bind(WorkflowGLSPDiagramClient).toSelf().inSingletonScope();
registerDiagramManager(bind, WorkflowDiagramManager);
export class WorkflowTheiaFrontendModule extends GLSPTheiaFrontendModule {
protected enableCopyPaste = true;

bindDiagramConfiguration(context: ContainerContext): void {
context.bind(DiagramConfiguration).to(WorkflowDiagramConfiguration);
}
readonly diagramLanguage = WorkflowLanguage;

configure(context: ContainerContext): void {
// Custom workflow commands and menus
context.bind(CommandContribution).to(WorkflowTaskEditCommandContribution);
context.bind(MenuContribution).to(WorkflowTaskEditMenuContribution);
context.bind(CommandContribution).to(WorkflowNavigationCommandContribution);
context.bind(MenuContribution).to(WorkflowNavigationMenuContribution);
context.bind(KeybindingContext).to(WorkflowDiagramKeybindingContext);
context.bind(KeybindingContribution).to(WorkflowKeybindingContribution);

// Example for a command that navigates to an element in a diagram with a query resolved by the server
context.bind(CommandContribution).to(ExampleNavigationCommandContribution).inSingletonScope();

// Optional default commands and menus
registerDiagramLayoutCommands(bind);
registerCopyPasteContextMenu(bind);
registerMarkerNavigationCommands(bind);
// Readonly workflow diagram view
context.bind(WorkflowDiagramReadonlyViewContribution).toSelf().inSingletonScope();
context.bind(MenuContribution).toService(WorkflowDiagramReadonlyViewContribution);
context.bind(CommandContribution).toService(WorkflowDiagramReadonlyViewContribution);
}

// Custom workflow commands and menus
bind(CommandContribution).to(WorkflowTaskEditCommandContribution).inSingletonScope();
bind(MenuContribution).to(WorkflowTaskEditMenuContribution).inSingletonScope();
bind(CommandContribution).to(WorkflowNavigationCommandContribution).inSingletonScope();
bind(MenuContribution).to(WorkflowNavigationMenuContribution).inSingletonScope();
bind(KeybindingContext).to(WorkflowDiagramKeybindingContext).inSingletonScope();
bind(KeybindingContribution).to(WorkflowKeybindingContribution).inSingletonScope();
}

// Example for a command that navigates to an element in a diagram with a query resolved by the server
bind(CommandContribution).to(ExampleNavigationCommandContribution).inSingletonScope();
export default new WorkflowTheiaFrontendModule();

// Readonly workflow diagram view
bind(WorkflowDiagramReadonlyViewContribution).toSelf().inSingletonScope();
bind(MenuContribution).toService(WorkflowDiagramReadonlyViewContribution);
bind(CommandContribution).toService(WorkflowDiagramReadonlyViewContribution);
});
18 changes: 10 additions & 8 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 EclipseSource and others.
* Copyright (c) 2019-2021 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 @@ -13,10 +13,12 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
export namespace WorkflowLanguage {
export const Id = 'Workflow';
export const Name = 'Workflow';
export const Label = 'Workflow diagram';
export const DiagramType = 'workflow-diagram';
export const FileExtension = '.wf';
}
import { GLSPDiagramLanguage } from '@eclipse-glsp/theia-integration/lib/common';

export const WorkflowLanguage: GLSPDiagramLanguage = {
contributionId: 'workflow',
label: 'Workflow diagram',
diagramType: 'workflow-diagram',
fileExtensions: ['.wf'],
iconClass: 'fa fa-project-diagram'
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019-2020 EclipseSource and others.
* Copyright (c) 2019-2021 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,8 +27,7 @@ export const JAR_FILE = resolve(join(SERVER_DIR, 'org.eclipse.glsp.example.workf

@injectable()
export class WorkflowGLServerContribution extends JavaSocketServerContribution {
readonly id = WorkflowLanguage.Id;
readonly name = WorkflowLanguage.Name;
readonly id = WorkflowLanguage.contributionId;

createLaunchOptions(): Partial<JavaSocketServerLaunchOptions> {
return {
Expand Down
7 changes: 3 additions & 4 deletions packages/theia-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@
},
"theiaExtensions": [
{
"frontend": "lib/browser/glsp-frontend-module",
"backend": "lib/node/glsp-backend-module"
"frontend": "lib/browser/theia-integration-frontend-module",
"backend": "lib/node/theia-integration-backend-module"
}
],
"publishConfig": {
"access": "public"
},
"main": "lib/index",
"types": "lib/index"
"main": "lib/browser/index"
}
Loading