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

GLSP-847 Drop dependency to sprotty-theia #149

Merged
merged 3 commits into from
Mar 16, 2023
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
3 changes: 1 addition & 2 deletions examples/browser-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
"@theia/preferences": "1.34.2",
"@theia/process": "1.34.2",
"@theia/terminal": "1.34.2",
"@theia/workspace": "1.34.2",
"sprotty-theia": "0.13.0-next.9cbedec"
"@theia/workspace": "1.34.2"
},
"devDependencies": {
"@theia/cli": "1.34.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import 'sprotty-theia/css/theia-sprotty.css';

import { createWorkflowDiagramContainer } from '@eclipse-glsp-examples/workflow-glsp/lib';
import { configureDiagramServer, GLSPDiagramConfiguration, GLSPTheiaDiagramServer } from '@eclipse-glsp/theia-integration';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019-2022 EclipseSource and others.
* Copyright (c) 2019-2023 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,9 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { ContainerContext, GLSPClientContribution, GLSPTheiaFrontendModule } from '@eclipse-glsp/theia-integration';
import { ContainerContext, DiagramConfiguration, GLSPClientContribution, GLSPTheiaFrontendModule } from '@eclipse-glsp/theia-integration';
import { CommandContribution, MenuContribution } from '@theia/core';
import { KeybindingContext, KeybindingContribution } from '@theia/core/lib/browser';
import { DiagramConfiguration } from 'sprotty-theia';
import { WorkflowLanguage } from '../common/workflow-language';
import { WorkflowDiagramConfiguration } from './diagram/workflow-diagram-configuration';
import { WorkflowDiagramReadonlyViewContribution } from './diagram/workflow-diagram-readonly-view';
Expand Down
138 changes: 138 additions & 0 deletions packages/theia-integration/css/sprotty-theia.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/********************************************************************************
* Copyright (c) 2017-2018 TypeFox 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
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

.sprotty {
display: flex;
height: 100%;
}

.sprotty svg {
width: 100%;
flex: 1;
border-style: solid;
border-width: 0px;
}

.sprotty svg:focus {
border-width: 0;
outline: none;
}

.sprotty-status {
position: absolute;
top: 5px;
left: 10px;
display: flex;
align-items: center;
}

.sprotty-status .fatal {
color: var(--theia-inputValidation-errorBorder);
}

.sprotty-status .error {
color: var(--theia-errorForeground);
}

.sprotty-status .warning {
color: var(--theia-editorWarning-foreground);
}

.sprotty-status .info {
color: var(--theia-editorInfo-foreground);
}

.sprotty-error {
fill: var(--theia-inputValidation-errorBackground);
color: var(--theia-errorForeground);
}

.sprotty-warning {
fill: var(--theia-inputValidation-warningBackground);
color: var(--theia-editorWarning-foreground);
}

.sprotty-info {
fill: var(--theia-info-color0);
color: var(--theia-inputValidation-infoBackground);
}

.sprotty-infoRow .codicon {
margin-right: 8px;
}
.sprotty-status .ok {
visibility: hidden;
}

.sprotty-status-message {
visibility: hidden;
padding-left: 10px;
}

.sprotty-status-message.fatal {
visibility: visible;
padding-left: 10px;
}

.sprotty-status:hover .sprotty-status-message {
visibility: visible;
}

.sprotty-popup {
position: absolute;
background: #ffe9be;
color: black;
border-radius: 0px;
border: none;
max-width: initial;
min-width: initial;
z-index: 1;
padding: 8px;
}

.sprotty-infoRow {
font-size: small;
margin-bottom: 8px;
}

.sprotty-infoTitle {
display: block;
font-weight: bold;
}

.sprotty-edge > .sprotty-routing-handle {
r: 5px;
fill: var(--theia-foreground);
stroke: none;
z-index: 1000;
}

.sprotty-edge > .sprotty-routing-handle[data-kind='line'] {
opacity: 0.35;
}

.sprotty-edge > .sprotty-routing-handle.selected {
fill: var(--theia-button-background);
}

.sprotty-edge > .sprotty-routing-handle.mouseover {
stroke: var(--theia-button-hoverBackground);
stroke-width: 1;
}

.sprotty-edge.mouseover:not(.selected) {
stroke-width: 3px;
}
7 changes: 4 additions & 3 deletions packages/theia-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@
"@eclipse-glsp/client": "next"
},
"peerDependencies": {
"@theia/core": "^1.34.2",
"@theia/messages": "^1.34.2",
"sprotty-theia": "0.13.0-next.9cbedec"
"@theia/core": "^1.34.0",
"@theia/filesystem": "^1.34.0",
"@theia/messages": "^1.34.0",
"@theia/monaco": "^1.34.0"
},
"publishConfig": {
"access": "public"
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-2023 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,15 +16,15 @@
import { MenuContribution, MenuModelRegistry } from '@theia/core';
import { CommonCommands } from '@theia/core/lib/browser';
import { injectable, interfaces } from '@theia/core/shared/inversify';
import { TheiaSprottyContextMenu } from 'sprotty-theia';
import { TheiaGLSPContextMenu } from './theia-glsp-context-menu-service';

export function registerCopyPasteContextMenu(bind: interfaces.Bind): void {
bind(MenuContribution).to(CopyPasteMenuContribution);
}

@injectable()
export class CopyPasteMenuContribution implements MenuContribution {
static readonly COPY_PASTE = TheiaSprottyContextMenu.CONTEXT_MENU.concat('copy-paste');
static readonly COPY_PASTE = TheiaGLSPContextMenu.CONTEXT_MENU.concat('copy-paste');
registerMenus(menus: MenuModelRegistry): void {
menus.registerMenuAction(CopyPasteMenuContribution.COPY_PASTE, {
commandId: CommonCommands.CUT.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify'
import { EditorManager } from '@theia/editor/lib/browser';
import { FileDialogService } from '@theia/filesystem/lib/browser/file-dialog/file-dialog-service';
import { FileService } from '@theia/filesystem/lib/browser/file-service';
import { DiagramWidget, TheiaDiagramServer } from 'sprotty-theia';
import { GLSPClientContribution } from '../glsp-client-contribution';
import { GLSPClientProvider } from '../glsp-client-provider';
import { deriveDiagramManagerId } from './glsp-diagram-manager';
import { GLSPDiagramWidget } from './glsp-diagram-widget';
import { GLSPMessageOptions, GLSPNotificationManager } from './glsp-notification-manager';
import { GLSPTheiaDiagramServer } from './glsp-theia-diagram-server';
import { TheiaGLSPConnector } from './theia-glsp-connector';

const SHOW_DETAILS_LABEL = 'Show details';
Expand Down Expand Up @@ -62,7 +63,7 @@ export abstract class BaseTheiaGLSPConnector implements TheiaGLSPConnector {
@inject(GLSPClientProvider)
protected readonly glspClientProvider: GLSPClientProvider;

private servers: Map<string, TheiaDiagramServer> = new Map();
private servers: Map<string, GLSPTheiaDiagramServer> = new Map();
private widgetMessages: Map<string, string[]> = new Map();
private widgetStatusTimeouts: Map<string, number> = new Map();

Expand All @@ -80,7 +81,7 @@ export abstract class BaseTheiaGLSPConnector implements TheiaGLSPConnector {
this.glspClientContribution = clientContribution;
}

connect(diagramServer: TheiaDiagramServer): void {
connect(diagramServer: GLSPTheiaDiagramServer): void {
this.servers.set(diagramServer.clientId, diagramServer);

this.glspClient.then(client => {
Expand All @@ -94,11 +95,11 @@ export abstract class BaseTheiaGLSPConnector implements TheiaGLSPConnector {
diagramServer.connect(this);
}

initializeClientSessionArgs(_diagramServer: TheiaDiagramServer): Args | undefined {
initializeClientSessionArgs(_diagramServer: GLSPTheiaDiagramServer): Args | undefined {
return undefined;
}

disconnect(diagramServer: TheiaDiagramServer): void {
disconnect(diagramServer: GLSPTheiaDiagramServer): void {
this.servers.delete(diagramServer.clientId);
this.glspClient.then(client =>
client.disposeClientSession({
Expand All @@ -109,7 +110,7 @@ export abstract class BaseTheiaGLSPConnector implements TheiaGLSPConnector {
diagramServer.disconnect();
}

disposeClientSessionArgs(_diagramServer: TheiaDiagramServer): Args | undefined {
disposeClientSessionArgs(_diagramServer: GLSPTheiaDiagramServer): Args | undefined {
return undefined;
}

Expand Down Expand Up @@ -154,7 +155,7 @@ export abstract class BaseTheiaGLSPConnector implements TheiaGLSPConnector {

// update status
const widget = this.widgetManager.getWidgets(this.diagramManagerId).find(w => w.id === widgetId);
if (widget instanceof DiagramWidget) {
if (widget instanceof GLSPDiagramWidget) {
widget.setStatus(status);
}

Expand Down Expand Up @@ -188,7 +189,7 @@ export abstract class BaseTheiaGLSPConnector implements TheiaGLSPConnector {

protected showServerMessage(widgetId: string, action: ServerMessageAction): void {
const widget = this.widgetManager.getWidgets(this.diagramManagerId).find(w => w.id === widgetId);
const uri = widget instanceof DiagramWidget ? widget.uri.toString() : '';
const uri = widget instanceof GLSPDiagramWidget ? widget.uri.toString() : '';

const type = this.toMessageType(action.severity);
const text = action.message;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/********************************************************************************
* Copyright (c) 2017-2018 TypeFox and others.
* Modifications: (c) 2023 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
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
// based on: https://github.com/eclipse-sprotty/sprotty-theia/blob/v0.12.0/src/theia/diagram-configuration.ts
import { InstanceRegistry } from '@eclipse-glsp/client';
import { Container, injectable, multiInject, optional } from 'inversify';

export const DiagramConfiguration = Symbol('DiagramConfiguration');

export interface DiagramConfiguration {
createContainer(widgetId: string): Container;
readonly diagramType: string;
}

@injectable()
export class DiagramConfigurationRegistry extends InstanceRegistry<DiagramConfiguration> {
constructor(@multiInject(DiagramConfiguration) @optional() diagramConfigs: DiagramConfiguration[]) {
super();
diagramConfigs.forEach(c => this.register(c.diagramType, c));
}
}
Loading