From 45531970a0c16db43799654bdd99f6fc80a23771 Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Tue, 17 Oct 2023 20:23:22 +0200 Subject: [PATCH 01/23] implemented dark theme synthesis support --- .../klighd-cli/src/services/connection.ts | 18 ++++++- .../klighd-vscode/src/klighd-extension.ts | 18 +++++++ packages/klighd-core/src/actions/actions.ts | 47 +++++++++++++++++++ packages/klighd-core/src/diagram-server.ts | 32 +++++++++++++ 4 files changed, 114 insertions(+), 1 deletion(-) diff --git a/applications/klighd-cli/src/services/connection.ts b/applications/klighd-cli/src/services/connection.ts index f6416e8f..95e5cab4 100644 --- a/applications/klighd-cli/src/services/connection.ts +++ b/applications/klighd-cli/src/services/connection.ts @@ -161,6 +161,17 @@ export class LSPConnection implements Connection { async sendInitialize(persistedData: Record): Promise { if (!this.connection) return; + // notify the server about the preferred colors, depending on if the OS prefers light (default) or dark theme. + let foreground = "#000000" + let background = "#ffffff" + let highlight = "#000000" + if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { + // dark mode + foreground = "#cccccc" + background = "#1f1f1f" + highlight = "#cccccc" + } + const method = lsp.InitializeRequest.type.method; // The standalone view does not really has any LSP capabilities const initParams: lsp.InitializeParams = { @@ -171,7 +182,12 @@ export class LSPConnection implements Connection { capabilities: {}, initializationOptions: { clientDiagramOptions: persistedData, - } + clientColorPreferences: { + foreground, + background, + highlight, + } + }, }; console.time("lsp-init"); diff --git a/applications/klighd-vscode/src/klighd-extension.ts b/applications/klighd-vscode/src/klighd-extension.ts index 603f7f84..72fc1db8 100644 --- a/applications/klighd-vscode/src/klighd-extension.ts +++ b/applications/klighd-vscode/src/klighd-extension.ts @@ -15,6 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 */ import { + ChangeColorThemeAction, KlighdFitToScreenAction, KlighdRequestExportSvgAction, RefreshDiagramAction, @@ -201,6 +202,23 @@ export class KLighDExtension extends SprottyLspVscodeExtension { * to overwrite commands and would throw an error._ */ protected override registerCommands(): void { + vscode.window.onDidChangeActiveColorTheme(() => { + // Hook into VS Code's theme change and notify the webview to check the current colors and send them to the server. + // Look for any active KLighD webview, regardless of if it is currently selected. + let webview = this.singleton + if (!webview) { + for (const possibleWebview of this.webviewMap.values()) { + if (possibleWebview.diagramPanel.active) { + webview = possibleWebview; + } + } + } + + if (webview) { + webview.dispatch(ChangeColorThemeAction.create()); + } + }) + this.context.subscriptions.push( commands.registerCommand(command.diagramOpen, async (...commandArgs: any[]) => { const identifier = await this.createDiagramIdentifier(commandArgs); diff --git a/packages/klighd-core/src/actions/actions.ts b/packages/klighd-core/src/actions/actions.ts index 4e3edea3..94834a59 100644 --- a/packages/klighd-core/src/actions/actions.ts +++ b/packages/klighd-core/src/actions/actions.ts @@ -90,6 +90,53 @@ export namespace CheckedImagesAction { } } +/** + * Sent internally to notify KLighD that the color theme has changed. Will trigger a subsequent + * ClientColorPreferencesAction to be triggered and sent. + */ +export interface ChangeColorThemeAction extends Action { + kind: typeof ChangeColorThemeAction.KIND +} + +export namespace ChangeColorThemeAction { + export const KIND = 'changeColorTheme' + + export function create(): ChangeColorThemeAction { + return { + kind: KIND, + } + } +} + +/** + * Action to notify the server about current color preferences. + */ +export interface ClientColorPreferencesAction extends Action { + kind: typeof ClientColorPreferencesAction.KIND + + clientColorPreferences: ColorPreferences +} + +export namespace ClientColorPreferencesAction { + export const KIND = 'changeClientColorPreferences' + + export function create(clientColorPreferences: ColorPreferences): ClientColorPreferencesAction { + return { + kind: KIND, + clientColorPreferences, + } + } +} + +/** + * The color preferences data class, indicating diagram colors to be used by syntheses. + */ +export interface ColorPreferences { + foreground: string, + background: string, + highlight: string, +} + /** * Sent from the client to the diagram server to perform a klighd action on the model. * Causes the server to update the diagram accordingly to the action. diff --git a/packages/klighd-core/src/diagram-server.ts b/packages/klighd-core/src/diagram-server.ts index 334822af..df4fbd25 100644 --- a/packages/klighd-core/src/diagram-server.ts +++ b/packages/klighd-core/src/diagram-server.ts @@ -47,14 +47,17 @@ import { ActionMessage, findElement, generateRequestId, + RequestModelAction, RequestPopupModelAction, SelectAction, SetPopupModelAction, UpdateModelAction, } from "sprotty-protocol"; import { + ChangeColorThemeAction, CheckedImagesAction, CheckImagesAction, + ClientColorPreferencesAction, KlighdExportSvgAction, KlighdFitToScreenAction, Pair, @@ -150,6 +153,10 @@ export class KlighdDiagramServer extends DiagramServerProxy { // In contract to the name, this should return true, if the actions should be // sent to the server. Don't know what the Sprotty folks where thinking when they named it... switch (action.kind) { + case ClientColorPreferencesAction.KIND: + return true; + case ChangeColorThemeAction.KIND: + return false; case PerformActionAction.KIND: return true; case RefreshDiagramAction.KIND: @@ -186,6 +193,8 @@ export class KlighdDiagramServer extends DiagramServerProxy { registry.register(BringToFrontAction.KIND, this); registry.register(CheckImagesAction.KIND, this); registry.register(CheckedImagesAction.KIND, this); + registry.register(ClientColorPreferencesAction.KIND, this); + registry.register(ChangeColorThemeAction.KIND, this); registry.register(DeleteLayerConstraintAction.KIND, this); registry.register(DeletePositionConstraintAction.KIND, this); registry.register(DeleteStaticConstraintAction.KIND, this); @@ -209,6 +218,18 @@ export class KlighdDiagramServer extends DiagramServerProxy { } handle(action: Action): void | ICommand | Action { + if (action.kind === RequestModelAction.KIND && getComputedStyle !== undefined) { + // On any request model action, also send the current colors with the request, so the initial + // syntheses can use the theming of VS Code. Values will be undefined outside of VS Code and should + // be ignored. + (action as RequestModelAction).options = { + ...((action as RequestModelAction).options), + clientColorPreferenceForeground: getComputedStyle(document.documentElement).getPropertyValue('--vscode-editor-foreground'), + clientColorPreferenceBackground: getComputedStyle(document.documentElement).getPropertyValue('--vscode-editor-background'), + clientColorPreferenceHighlight: getComputedStyle(document.documentElement).getPropertyValue('--vscode-focusBorder') + } + super.handle(action) + } if (action.kind === BringToFrontAction.KIND || action.kind === SwitchEditModeAction.KIND) { // Actions that should be ignored and not further handled by this diagram server @@ -217,6 +238,8 @@ export class KlighdDiagramServer extends DiagramServerProxy { if (action.kind === CheckImagesAction.KIND) { this.handleCheckImages(action as CheckImagesAction); + } else if (action.kind === ChangeColorThemeAction.KIND) { + this.handleChangeColorTheme(); } else if (action.kind === StoreImagesAction.KIND) { this.handleStoreImages(action as StoreImagesAction); } else if (action.kind === RequestPopupModelAction.KIND) { @@ -248,6 +271,15 @@ export class KlighdDiagramServer extends DiagramServerProxy { this.actionDispatcher.dispatch(CheckedImagesAction.create(notCached)); } + handleChangeColorTheme(): void { + if (getComputedStyle === undefined) return + this.actionDispatcher.dispatch(ClientColorPreferencesAction.create({ + foreground: getComputedStyle(document.documentElement).getPropertyValue('--vscode-editor-foreground'), + background: getComputedStyle(document.documentElement).getPropertyValue('--vscode-editor-background'), + highlight: getComputedStyle(document.documentElement).getPropertyValue('--vscode-focusBorder'), + })) + } + handleStoreImages(action: StoreImagesAction): void { // Put the new images in session storage. for (const imagePair of (action as StoreImagesAction).images) { From e1cf0b0b6b3290df6619e4919b74ca0d5dec0ee2 Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Sat, 28 Sep 2024 21:34:50 +0200 Subject: [PATCH 02/23] implement client-only layout. Hardcode to use it for now, switch between modes missing yet. --- packages/klighd-core/package.json | 2 + packages/klighd-core/src/di.config.ts | 21 ++++++++- packages/klighd-core/src/diagram-server.ts | 36 +++++++++++++++ packages/klighd-core/src/layout-config.ts | 41 +++++++++++++++++ packages/klighd-core/src/skgraph-models.ts | 5 ++- packages/klighd-core/src/views-common.ts | 51 ++++++++++++++-------- yarn.lock | 15 +++++++ 7 files changed, 151 insertions(+), 20 deletions(-) create mode 100644 packages/klighd-core/src/layout-config.ts diff --git a/packages/klighd-core/package.json b/packages/klighd-core/package.json index 6abb4798..8b420388 100644 --- a/packages/klighd-core/package.json +++ b/packages/klighd-core/package.json @@ -26,11 +26,13 @@ "dependencies": { "@kieler/klighd-interactive": "^0.5.0", "@types/file-saver": "^2.0.7", + "elkjs": "^0.8.2", "feather-icons": "^4.29.1", "file-saver": "^2.0.5", "inversify": "^6.0.2", "snabbdom": "^3.5.1", "sprotty": "^1.3.0", + "sprotty-elk": "^1.3.0", "sprotty-protocol": "^1.3.0" }, "devDependencies": { diff --git a/packages/klighd-core/src/di.config.ts b/packages/klighd-core/src/di.config.ts index f31ccb7e..1f62a620 100644 --- a/packages/klighd-core/src/di.config.ts +++ b/packages/klighd-core/src/di.config.ts @@ -16,8 +16,10 @@ */ import { interactiveModule } from '@kieler/klighd-interactive/lib/interactive-module' +import ElkConstructor from 'elkjs/lib/elk.bundled' import { Container, ContainerModule, interfaces } from 'inversify' import { + boundsModule, configureActionHandler, configureModelElement, ConsoleLogger, @@ -44,6 +46,7 @@ import { viewportModule, ViewRegistry, } from 'sprotty' +import { ElkFactory, ElkLayoutEngine, elkLayoutModule, ILayoutConfigurator } from 'sprotty-elk' import actionModule from './actions/actions-module' // import bookmarkModule from './bookmarks/bookmark-module'; import { DISymbol } from './di.symbols' @@ -53,6 +56,7 @@ import { KlighdHoverMouseListener } from './hover/hover' import { PopupModelProvider } from './hover/popup-provider' import { KlighdMouseTool } from './klighd-mouse-tool' import { KlighdSvgExporter } from './klighd-svg-exporter' +import { KielerLayoutConfigurator } from './layout-config' import { KlighdModelViewer } from './model-viewer' import { ResetPreferencesAction, SetPreferencesAction } from './options/actions' import { optionsModule } from './options/options-module' @@ -74,6 +78,16 @@ const kGraphDiagramModule = new ContainerModule( bind(TYPES.ModelSource).to(KlighdDiagramServer).inSingletonScope() rebind(TYPES.ILogger).to(ConsoleLogger).inSingletonScope() rebind(TYPES.LogLevel).toConstantValue(LogLevel.warn) + + // required binding for elkjs to work + bind(TYPES.IModelLayoutEngine).toService(ElkLayoutEngine) + + // Our own layout configurator that just copies the element's poperties as the layout options. + bind(KielerLayoutConfigurator).toSelf().inSingletonScope() + rebind(ILayoutConfigurator).to(KielerLayoutConfigurator).inSingletonScope() + const elkFactory: ElkFactory = () => new ElkConstructor({ algorithms: ['layered'] }) // See elkjs documentation + bind(ElkFactory).toConstantValue(elkFactory) + rebind(TYPES.CommandStackOptions).toConstantValue({ // Override the default animation speed to be 500 ms, as the default value is too quick. defaultDuration: 500, @@ -126,6 +140,8 @@ export default function createContainer(widgetId: string): Container { const container = new Container() container.load( defaultModule, + boundsModule, + elkLayoutModule, selectModule, interactiveModule, viewportModule, @@ -144,8 +160,9 @@ export default function createContainer(widgetId: string): Container { ) // FIXME: bookmarkModule is currently broken due to wrong usage of Sprotty commands. action handling needs to be reimplemented for this to work. overrideViewerOptions(container, { - needsClientLayout: false, - needsServerLayout: true, + // TODO: need some configuration switch to enable/disable client layout + needsClientLayout: true, // client layout = micro layout (Sprotty/Sprotty+KLighD) + needsServerLayout: false, // server layout = macro layout (ELK/elkjs). false here to not forward it to the Java server (the model source), but keep and handle it directly on the diagram server proxy manually baseDiv: widgetId, hiddenDiv: `${widgetId}_hidden`, // TODO: We should be able to completely deactivate Sprotty's zoom limits to not limit top down layout. diff --git a/packages/klighd-core/src/diagram-server.ts b/packages/klighd-core/src/diagram-server.ts index dbf682dd..4796f2a0 100644 --- a/packages/klighd-core/src/diagram-server.ts +++ b/packages/klighd-core/src/diagram-server.ts @@ -48,13 +48,18 @@ import { import { Action, ActionMessage, + ComputedBoundsAction, BringToFrontAction, findElement, generateRequestId, + IModelLayoutEngine, + RequestModelAction, GetViewportAction, RequestPopupModelAction, SelectAction, + SetModelAction, SetPopupModelAction, + SModelRoot, UpdateModelAction, ViewportResult, } from 'sprotty-protocol' @@ -106,6 +111,8 @@ export class KlighdDiagramServer extends DiagramServerProxy { @inject(DISymbol.BookmarkRegistry) @optional() private bookmarkRegistry: BookmarkRegistry + @inject(TYPES.IModelLayoutEngine) @optional() protected layoutEngine?: IModelLayoutEngine + constructor(@inject(ServiceTypes.Connection) connection: Connection) { super() this._connection = connection @@ -301,6 +308,35 @@ export class KlighdDiagramServer extends DiagramServerProxy { return false } + // Behavior adapted from the super class and modified to the behavior of the DiagramServer to allow this proxy to the Java diagram server to still be able to perform the layout locally. + handleComputedBounds(action: ComputedBoundsAction): boolean { + if (this.viewerOptions.needsServerLayout) { + return false + } + const root = this.currentRoot + this.computedBoundsApplicator.apply(root, action) + this.doSubmitModel(root, root.type === this.lastSubmittedModelType, action) + return false + } + + // Behavior taken from the DiagramServer to allow this proxy to the Java diagram server to still be able to perform the layout locally. + private async doSubmitModel(newRoot: SModelRoot, update: boolean, cause?: Action): Promise { + if (this.layoutEngine) { + newRoot = await this.layoutEngine.layout(newRoot) + } + const modelType = newRoot.type + if (cause && cause.kind === RequestModelAction.KIND) { + const { requestId } = cause as RequestModelAction + const response = SetModelAction.create(newRoot, requestId) + this.actionDispatcher.dispatch(response) + } else if (update && modelType === this.lastSubmittedModelType) { + this.actionDispatcher.dispatch(UpdateModelAction.create(newRoot)) + } else { + this.actionDispatcher.dispatch(SetModelAction.create(newRoot)) + } + this.lastSubmittedModelType = modelType + } + handleRequestDiagramPiece(action: RequestDiagramPieceAction): void { this.forwardToServer(action) } diff --git a/packages/klighd-core/src/layout-config.ts b/packages/klighd-core/src/layout-config.ts new file mode 100644 index 00000000..92b29dbb --- /dev/null +++ b/packages/klighd-core/src/layout-config.ts @@ -0,0 +1,41 @@ +/* + * KIELER - Kiel Integrated Environment for Layout Eclipse RichClient + * + * http://rtsys.informatik.uni-kiel.de/kieler + * + * Copyright 2024 by + * + Kiel University + * + Department of Computer Science + * + Real-Time and Embedded Systems Group + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + */ + +import { LayoutOptions } from 'elkjs' +import { DefaultLayoutConfigurator } from 'sprotty-elk' +import { SModelElement, SModelIndex } from 'sprotty-protocol' + +/** + * This layout configurator copies all layout options from the KGraph element's properties. + */ +export class KielerLayoutConfigurator extends DefaultLayoutConfigurator { + override apply(element: SModelElement, _index: SModelIndex): LayoutOptions | undefined { + // Only apply to elements with properties. + if ((element as any).properties === undefined) { + return undefined + } + const properties = (element as any).properties as Record + + // map properties to layout options and stringify values + const layoutOptions: LayoutOptions = {} + Object.entries(properties).forEach(([key, value]) => { + layoutOptions[key] = JSON.stringify(value) + }) + + return layoutOptions + } +} diff --git a/packages/klighd-core/src/skgraph-models.ts b/packages/klighd-core/src/skgraph-models.ts index 91dfb0ff..4a52511a 100644 --- a/packages/klighd-core/src/skgraph-models.ts +++ b/packages/klighd-core/src/skgraph-models.ts @@ -18,6 +18,7 @@ import { KEdge, KGraphData, KNode, SKGraphElement } from '@kieler/klighd-interactive/lib/constraint-classes' import { boundsFeature, + layoutContainerFeature, moveFeature, popupFeature, RectangularPort, @@ -40,6 +41,8 @@ export class SKNode extends KNode { hasFeature(feature: symbol): boolean { return ( feature === selectFeature || + feature === boundsFeature || + feature === layoutContainerFeature || (feature === moveFeature && (this.parent as SKNode).properties && ((this.parent as SKNode).properties['org.eclipse.elk.interactiveLayout'] as boolean)) || @@ -61,7 +64,7 @@ export class SKPort extends RectangularPort implements SKGraphElement { areNonChildAreaChildrenRendered = false hasFeature(feature: symbol): boolean { - return feature === selectFeature || feature === popupFeature + return feature === selectFeature || feature === boundsFeature || feature === popupFeature } properties: Record diff --git a/packages/klighd-core/src/views-common.ts b/packages/klighd-core/src/views-common.ts index e03482aa..cebaf61b 100644 --- a/packages/klighd-core/src/views-common.ts +++ b/packages/klighd-core/src/views-common.ts @@ -3,7 +3,7 @@ * * http://rtsys.informatik.uni-kiel.de/kieler * - * Copyright 2019-2023 by + * Copyright 2019-2024 by * + Kiel University * + Department of Computer Science * + Real-Time and Embedded Systems Group @@ -420,14 +420,14 @@ export function findBoundsAndTransformationData( } } } - // Error check: If there are no bounds or decoration, at least try to fall back to possible size and position attributes in the parent element. + // Error check: If there are no bounds or decoration, at least try to fall back to possible position attributes in the parent element. // If the parent element has no bounds either, the object can not be rendered. - if (decoration === undefined && bounds === undefined && 'size' in parent && 'position' in parent) { + if (decoration === undefined && bounds === undefined && 'bounds' in parent) { bounds = { - x: (parent as any).position.x, - y: (parent as any).position.y, - width: (parent as any).size.width, - height: (parent as any).size.height, + x: 0, + y: 0, + width: (parent as any).bounds.width, + height: (parent as any).bounds.height, } } else if (decoration === undefined && bounds === undefined) { return undefined @@ -573,16 +573,33 @@ export function findTextBoundsAndTransformationData( bounds.height = decoration.bounds.height } } - // Error check: If there are no bounds or decoration, at least try to fall back to possible size and position attributes in the parent element. - // If the parent element has no bounds either, the object can not be rendered. - if (decoration === undefined && bounds.x === undefined && 'size' in parent && 'position' in parent) { - bounds.x = (parent as any).position.x - bounds.y = (parent as any).position.y - bounds.width = (parent as any).size.width - bounds.height = (parent as any).size.height - } else if (decoration === undefined && bounds.x === undefined) { - return undefined - } + } + // Error check: If there are no bounds or decoration, at least try to fall back to possible size attributes in the parent element. + // If the parent element has no bounds either, the object can not be rendered. + if (decoration === undefined && bounds.x === undefined && 'bounds' in parent) { + const parentBounds = { + x: 0, + y: 0, + width: (parent as any).bounds.width, + height: (parent as any).bounds.height, + } + + bounds.x = calculateX( + parentBounds.x, + parentBounds.width, + styles.kHorizontalAlignment ?? DEFAULT_K_HORIZONTAL_ALIGNMENT, + parentBounds.width + ) + bounds.y = calculateY( + parentBounds.y, + parentBounds.height, + styles.kVerticalAlignment ?? DEFAULT_K_VERTICAL_ALIGNMENT, + lines + ) + bounds.width = parent.bounds.width + bounds.height = parent.bounds.height + } else if (decoration === undefined && bounds.x === undefined) { + return undefined } // If still no bounds are found, set all by default to 0. diff --git a/yarn.lock b/yarn.lock index 9689aecb..2c00c992 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3827,6 +3827,11 @@ electron-to-chromium@^1.4.535: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.585.tgz#7b3cb6846bb5cc10a8d5904c351a9b8aaa76ea90" integrity sha512-B4yBlX0azdA3rVMxpYwLQfDpdwOgcnLCkpvSOd68iFmeedo+WYjaBJS3/W58LVD8CB2nf+o7C4K9xz1l09RkWg== +elkjs@^0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/elkjs/-/elkjs-0.8.2.tgz#c37763c5a3e24e042e318455e0147c912a7c248e" + integrity sha512-L6uRgvZTH+4OF5NE/MBbzQx/WYpru1xCBE9respNj6qznEewGUIfhzmm7horWWxbNO2M0WckQypGctR8lH79xQ== + elliptic@^6.5.3: version "6.5.4" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" @@ -8685,6 +8690,16 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= +sprotty-elk@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/sprotty-elk/-/sprotty-elk-1.3.0.tgz#2cffc8ff280f899ca791c011d67ccb4a0cd50e5e" + integrity sha512-P8AZxWj99RziRK+mA6D/J99PvpT4z+gAVbfvaHJHhYXW+1jDP5vJSNzhW305BykfFugN+2V0HVSLZKana+aUHg== + dependencies: + elkjs "^0.8.2" + sprotty-protocol "^1.3.0" + optionalDependencies: + inversify "~6.0.2" + sprotty-protocol@^1.0.0, sprotty-protocol@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/sprotty-protocol/-/sprotty-protocol-1.3.0.tgz#78a6a69cc5eb8b94b352882a83d0f339fd828a0d" From 660e9fa6cf65f9ff6092c4af89d5f7c8a988cbeb Mon Sep 17 00:00:00 2001 From: Max Kasperowski Date: Tue, 8 Oct 2024 11:14:15 +0200 Subject: [PATCH 03/23] add schema for SKGraph structure --- schema/SKGraphSchema.json | 305 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 305 insertions(+) create mode 100644 schema/SKGraphSchema.json diff --git a/schema/SKGraphSchema.json b/schema/SKGraphSchema.json new file mode 100644 index 00000000..4a4083ef --- /dev/null +++ b/schema/SKGraphSchema.json @@ -0,0 +1,305 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/SKGraphSchema.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "SKElement", + "type": "object", + "properties": { + "data": { + "type": "array", + "items": [ + { + "$ref": "#/definitions/KGraphData" + } + ], + "default": [] + }, + "properties": { + "type": "object", + "default": {} + }, + "type": { + "type": "string" + } + }, + "definitions": { + "SModelElement": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "id": { + "type": "string" + }, + "children": { + "type": "array", + "items": [ + { + "$ref": "#/definitions/SModelElement" + } + ], + "default": [] + }, + "trace": { + "type": "string" + } + } + }, + "SShapeElement": { + "allOf": [{"$ref": "#/definitions/SModelElement"}], + "properties": { + "size": { + "type": "object", + "properties": { + "width": { + "type": "number" + }, + "height": { + "type": "number" + } + }, + "default": { "width": 0.0, "height": 0.0 } + } + } + + }, + "SKGraph": { + "allOf": [{"$ref": "#"}, {"$ref": "#/definitions/SModelElement"}], + "properties": { + "type": { + "type": "string", + "default": "graph" + }, + "revision": { + "type": "number" + } + } + }, + "SKNode": { + "allOf": [{"$ref": "#"}, {"$ref": "#/definitions/SShapeElement"}], + "properties": { + "type": { + "type": "string", + "default": "node" + } + } + }, + "SKLabel": { + "allOf": [{"$ref": "#"}, {"$ref": "#/definitions/SModelElement"}], + "properties": { + "text": { + "type": "string" + }, + "type": { + "type": "string", + "default": "label" + } + } + }, + "SKEdge": { + "allOf": [{"$ref": "#"}, {"$ref": "#/definitions/SModelElement"}], + "properties": { + "sourceId": { + "type": "string" + }, + "targetId": { + "type": "string" + }, + "junctionPoints": { + "type": "array", + "items": [ + { + "type": "object", + "properties": { + "x": { + "type": "number" + }, + "y": { + "type": "number" + } + } + } + ], + "default": [] + }, + "type": { + "type": "string", + "default": "edge" + } + } + }, + "SKPort": { + "allOf": [{"$ref": "#"}, {"$ref": "#/definitions/SShapeElement"}], + "properties": { + "type": { + "type": "string", + "default": "port" + } + } + }, + "KGraphData": { + "properties": { + "properties": { + "type": "object", + "default": {} + } + } + }, + "KRendering": { + "allOf": [{"$ref": "#/definitions/KGraphData"}], + "properties": { + "placementData": { + "$ref": "#/definitions/KPlacementData" + }, + "styles": { + "type": "array", + "default": [] + }, + "actions": { + "type": "array", + "default": [] + }, + "type": { + "type": "string", + "default": "KRenderingImpl" + } + } + }, + "KContainerRendering": { + "allOf": [{"$ref": "#/definitions/KRendering"}], + "properties": { + "children": { + "type": "array", + "items": [ + {"$ref": "#/definitions/KRendering"} + ], + "default": [] + + }, + "childPlacement": { + + }, + "type": { + "type": "string", + "default": "KContainerRenderingImpl" + } + } + }, + "KRectangle": { + "allOf": [{"$ref": "#/definitions/KContainerRendering"}], + "properties": { + "type": { + "type": "string", + "default": "KRectangleImpl" + } + } + }, + "KRoundedRectangle": { + "allOf": [{"$ref": "#/definitions/KRectangle"}], + "properties": { + "cornerWidth": { + "type": "number" + }, + "cornerHeight": { + "type": "number" + }, + "type": { + "type": "string", + "default": "KRoundedRectangleImpl" + } + } + }, + "KPolyline": { + "allOf": [{"$ref": "#/definitions/KContainerRendering"}], + "properties": { + "type": { + "type": "string", + "default": "KPolylineImpl" + }, + "junctionPointRendering": { + "$ref": "#/definitions/KRendering" + } + } + }, + "KPolygon": { + "allOf": [{"$ref": "#/definitions/KPolyline"}], + "properties": { + "type": { + "type": "string", + "default": "KPolygonImpl" + } + } + }, + "KSpline": { + "allOf": [{"$ref": "#/definitions/KPolyline"}], + "properties": { + "type": { + "type": "string", + "default": "KSplineImpl" + } + } + }, + "KImage": { + "allOf": [{"$ref": "#/definitions/KContainerRendering"}], + "properties": { + "bundleName": { + "type": "string" + }, + "imagePath": { + "type": "string" + }, + "type": { + "type": "string", + "default": "KImageImpl" + } + } + }, + "KEllipse": { + "allOf": [{"$ref": "#/definitions/KContainerRendering"}], + "properties": { + "type": { + "type": "string", + "default": "KEllipseImpl" + } + } + }, + "KArc": { + "allOf": [{"$ref": "#/definitions/KContainerRendering"}], + "properties": { + "startAngle": { + "type": "number" + }, + "arcAngle": { + "type": "number" + }, + "type": { + "type": "string", + "default": "KArcImpl" + } + } + }, + "KText": { + "allOf": [{"$ref": "#/definitions/KContainerRendering"}], + "properties": { + "text": { + "type": "string" + }, + "clip": { + "type": "boolean" + }, + "type": { + "type": "string", + "default": "KTextImpl" + } + } + }, + "KPlacementData": { + "type": "object", + "properties": { + "stub": { + "type": "string" + } + } + } + } +} \ No newline at end of file From e186312f3e5b110e092427f1c956350b98d8c0bc Mon Sep 17 00:00:00 2001 From: Max Kasperowski Date: Wed, 9 Oct 2024 15:10:46 +0200 Subject: [PATCH 04/23] add json schemas for messages and actions used to speak with a language server --- schema/{ => klighd}/SKGraphSchema.json | 2 +- schema/klighd/actions/setSyntheses.json | 32 +++++ schema/klighd/actions/updateOptions.json | 158 +++++++++++++++++++++ schema/klighd/messages/setPreferences.json | 29 ++++ schema/lsp/initialize.json | 61 ++++++++ schema/sprotty/actions/requestBounds.json | 34 +++++ schema/sprotty/messages/diagramAccept.json | 67 +++++++++ 7 files changed, 382 insertions(+), 1 deletion(-) rename schema/{ => klighd}/SKGraphSchema.json (99%) create mode 100644 schema/klighd/actions/setSyntheses.json create mode 100644 schema/klighd/actions/updateOptions.json create mode 100644 schema/klighd/messages/setPreferences.json create mode 100644 schema/lsp/initialize.json create mode 100644 schema/sprotty/actions/requestBounds.json create mode 100644 schema/sprotty/messages/diagramAccept.json diff --git a/schema/SKGraphSchema.json b/schema/klighd/SKGraphSchema.json similarity index 99% rename from schema/SKGraphSchema.json rename to schema/klighd/SKGraphSchema.json index 4a4083ef..5305f351 100644 --- a/schema/SKGraphSchema.json +++ b/schema/klighd/SKGraphSchema.json @@ -1,5 +1,5 @@ { - "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/SKGraphSchema.json", + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/SKGraphSchema.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "SKElement", "type": "object", diff --git a/schema/klighd/actions/setSyntheses.json b/schema/klighd/actions/setSyntheses.json new file mode 100644 index 00000000..79398e2e --- /dev/null +++ b/schema/klighd/actions/setSyntheses.json @@ -0,0 +1,32 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/actions/setSyntheses.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "setSyntheses", + "type": "object", + "allOf": [{"$ref": "../../sprotty/messages/diagramAccept.json#/definitions/action"}], + "properties": { + "kind": { + "type": "string", + "enum": ["setSyntheses"] + }, + "syntheses": { + "type": "array", + "items": { + "$ref": "#/definitions/synthesis" + } + } + }, + "definitions": { + "synthesis": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "displayName": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/schema/klighd/actions/updateOptions.json b/schema/klighd/actions/updateOptions.json new file mode 100644 index 00000000..4294ed71 --- /dev/null +++ b/schema/klighd/actions/updateOptions.json @@ -0,0 +1,158 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/actions/updateOptions.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "updateOptions", + "type": "object", + "allOf": [{"$ref": "../../sprotty/messsages/diagramAccept.json#/definitions/action"}], + "properties": { + "kind": { + "type": "string", + "enum": ["updateOptions"] + }, + "valuedSynthesisOptions": { + "type": "array", + "items": { + "$ref": "#/definitions/SynthesisOption" + } + }, + "layoutOptions": { + "type": "array" + }, + "actions": { + "type": "array" + }, + "modelUri": { + "type": "string" + } + }, + "definitions": { + "SynthesisOption": { + "type": "object", + "properties": { + "synthesisOption": { + "anyOf": [ + {"$ref": "#/definitions/checkSynthesisOption"}, + {"$ref": "#/definitions/choiceSynthesisOption"}, + {"$ref": "#/definitions/rangeSynthesisOption"}, + {"$ref": "#/definitions/textSynthesisOption"}, + {"$ref": "#/definitions/separatorSynthesisOption"} + ] + }, + "currentValue": { + "type": ["string", "number", "boolean"] + } + } + }, + "generalSynthesisOption": { + "type": "object", + "properties": { + + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "type": { + "type": "number" + }, + "updateAction": { + "type": "string" + }, + "category": { + "$ref": "#/definitions/SynthesisCategory" + }, + "sourceHash": { + "type": "string" + }, + "initialValue": {} + } + }, + "checkSynthesisOption": { + "allOf": [{"$ref": "#/definitions/generalSynthesisOption"}], + "properties": { + "type": { + "type": "number", + "enum": [0] + }, + "initialValue": { + "type": "boolean" + } + } + }, + "choiceSynthesisOption": { + "allOf": [{"$ref": "#/definitions/generalSynthesisOption"}], + "properties": { + "type": { + "type": "number", + "enum": [1] + }, + "initialValue": { + "type": "string" + }, + "values": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "rangeSynthesisOption": { + "allOf": [{"$ref": "#/definitions/generalSynthesisOption"}], + "properties": { + "type": { + "type": "number", + "enum": [2] + }, + "initialValue": { + "type": "number" + }, + "range": { + "type": "object", + "properties": { + "first": { + "type": "number" + }, + "second": { + "type": "number" + } + } + }, + "stepSize": { + "type": "number" + } + } + }, + "textSynthesisOption": { + "allOf": [{"$ref": "#/definitions/generalSynthesisOption"}], + "properties": { + "type": { + "type": "number", + "enum": [3] + }, + "initialValue": { + "type": "string" + } + } + }, + "separatorSynthesisOption": { + "allOf": [{"$ref": "#/definitions/generalSynthesisOption"}], + "properties": { + "type": { + "type": "number", + "enum": [4] + } + } + }, + "categorySynthesisOption": { + "allOf": [{"$ref": "#/definitions/generalSynthesisOption"}], + "properties": { + "type": { + "type": "number", + "enum": [5] + } + } + } + } +} \ No newline at end of file diff --git a/schema/klighd/messages/setPreferences.json b/schema/klighd/messages/setPreferences.json new file mode 100644 index 00000000..75a37b7a --- /dev/null +++ b/schema/klighd/messages/setPreferences.json @@ -0,0 +1,29 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/messages/setPreferences.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "keith/preferences/setPreferences", + "type": "object", + "properties": { + "jsonrpc": { + "type": "string" + }, + "method": { + "type": "string", + "enum": ["keith/preferences/setPreferences"] + }, + "params": { + "type": "object", + "properties": { + "diagram.shouldSelectDiagram": { + "type": "boolean" + }, + "diagram.shouldSelectText": { + "type": "boolean" + }, + "diagram.incrementalDiagramGenerator": { + "type": "boolean" + } + } + } + } +} \ No newline at end of file diff --git a/schema/lsp/initialize.json b/schema/lsp/initialize.json new file mode 100644 index 00000000..8d9f2e8d --- /dev/null +++ b/schema/lsp/initialize.json @@ -0,0 +1,61 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/lsp/initialize.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "initialize", + "type": "object", + "properties": { + "jsonrpc": { + "type": "string" + }, + "id": { + "type": "number" + }, + "method": { + "type": "string", + "enum": ["initialize"] + }, + "params": { + "type": "object", + "properties": { + "processId": {}, + "workspaceFolders": {}, + "rootUri": {}, + "clientInfo": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + } + }, + "capabilities": { + "type": "object" + }, + "initializationOptions": { + "type": "object", + "properties": { + "clientDiagramOptions": { + "$ref": "#/definitions/ClientDiagramOptions" + } + } + } + } + } + }, + "definitions": { + "ClientDiagramOptions": { + "type": "object", + "properties": { + "preference": { + "type": "object" + }, + "render": { + "type": "object" + }, + "synthesis": { + "type": "object" + } + } + } + } +} \ No newline at end of file diff --git a/schema/sprotty/actions/requestBounds.json b/schema/sprotty/actions/requestBounds.json new file mode 100644 index 00000000..d65e8c52 --- /dev/null +++ b/schema/sprotty/actions/requestBounds.json @@ -0,0 +1,34 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/messages/requestBounds.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "requestBounds", + "type": "object", + "allOf": [{"$ref": "../../sprotty/messages/diagramAccept.json#/definitions/action"}], + "properties": { + "kind": { + "type": "string", + "enum": ["requestBounds"] + }, + "newRoot": { + "type": "object", + "properties": { + "properties": {}, + "revision": { + "type": "number" + }, + "type": { + "type": "string" + }, + "id": { + "type": "string" + }, + "children": { + "type": "array", + "items": { + "$ref": "../../klighd/SKGraphSchema#/definitions/SKGraph" + } + } + } + } + } +} \ No newline at end of file diff --git a/schema/sprotty/messages/diagramAccept.json b/schema/sprotty/messages/diagramAccept.json new file mode 100644 index 00000000..b8fb5b86 --- /dev/null +++ b/schema/sprotty/messages/diagramAccept.json @@ -0,0 +1,67 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/messages/diagramAccept.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "diagram/accept", + "type": "object", + "properties": { + "jsonrpc": { + "type": "string" + }, + "method": { + "type": "string", + "enum": ["diagram/accept"] + }, + "params": { + "type": "object", + "properties": { + "clientId": { + "type": "string", + "enum": ["sprotty"] + }, + "action": { + "$ref": "#/definitions/action" + } + } + } + }, + "definitions": { + "action": { + "type": "object", + "properties": { + "kind": { + "type": "string" + } + } + }, + "requestModelAction": { + "allOf": [{"$ref": "#/definitions/action"}], + "properties": { + "kind": { + "type": "string", + "enum": ["requestModel"] + }, + "options": { + "type": "object", + "properties": { + "needsClientLayout": { + "type": "boolean" + }, + "needsServerLayout": { + "type": "boolean" + }, + "sourceUri": { + "type": "string" + }, + "diagramType": { + "type": "string", + "enum": ["keith-diagram"] + } + } + }, + "requestId": { + "type": "string" + } + } + } + } +} \ No newline at end of file From df3cd18441b6bb5dbd03892e1565e62dcd0f1205 Mon Sep 17 00:00:00 2001 From: Max Kasperowski Date: Wed, 9 Oct 2024 15:48:26 +0200 Subject: [PATCH 05/23] update schema structure --- schema/klighd/actions/setSyntheses.json | 2 +- schema/klighd/actions/updateOptions.json | 28 +++++---- schema/sprotty/actions/action.json | 11 ++++ schema/sprotty/actions/requestBounds.json | 6 +- schema/sprotty/actions/requestModel.json | 34 +++++++++++ schema/sprotty/diagramAccept.json | 27 +++++++++ schema/sprotty/messages/diagramAccept.json | 67 ---------------------- 7 files changed, 92 insertions(+), 83 deletions(-) create mode 100644 schema/sprotty/actions/action.json create mode 100644 schema/sprotty/actions/requestModel.json create mode 100644 schema/sprotty/diagramAccept.json delete mode 100644 schema/sprotty/messages/diagramAccept.json diff --git a/schema/klighd/actions/setSyntheses.json b/schema/klighd/actions/setSyntheses.json index 79398e2e..021faf00 100644 --- a/schema/klighd/actions/setSyntheses.json +++ b/schema/klighd/actions/setSyntheses.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "setSyntheses", "type": "object", - "allOf": [{"$ref": "../../sprotty/messages/diagramAccept.json#/definitions/action"}], + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], "properties": { "kind": { "type": "string", diff --git a/schema/klighd/actions/updateOptions.json b/schema/klighd/actions/updateOptions.json index 4294ed71..3a2b6f39 100644 --- a/schema/klighd/actions/updateOptions.json +++ b/schema/klighd/actions/updateOptions.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "updateOptions", "type": "object", - "allOf": [{"$ref": "../../sprotty/messsages/diagramAccept.json#/definitions/action"}], + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], "properties": { "kind": { "type": "string", @@ -12,7 +12,7 @@ "valuedSynthesisOptions": { "type": "array", "items": { - "$ref": "#/definitions/SynthesisOption" + "$ref": "#/definitions/ValuedSynthesisOption" } }, "layoutOptions": { @@ -26,7 +26,7 @@ } }, "definitions": { - "SynthesisOption": { + "ValuedSynthesisOption": { "type": "object", "properties": { "synthesisOption": { @@ -35,7 +35,8 @@ {"$ref": "#/definitions/choiceSynthesisOption"}, {"$ref": "#/definitions/rangeSynthesisOption"}, {"$ref": "#/definitions/textSynthesisOption"}, - {"$ref": "#/definitions/separatorSynthesisOption"} + {"$ref": "#/definitions/separatorSynthesisOption"}, + {"$ref": "#/definitions/categorySynthesisOption"} ] }, "currentValue": { @@ -43,7 +44,7 @@ } } }, - "generalSynthesisOption": { + "SynthesisOption": { "type": "object", "properties": { @@ -60,7 +61,7 @@ "type": "string" }, "category": { - "$ref": "#/definitions/SynthesisCategory" + "$ref": "#/definitions/categorySynthesisOption" }, "sourceHash": { "type": "string" @@ -69,7 +70,7 @@ } }, "checkSynthesisOption": { - "allOf": [{"$ref": "#/definitions/generalSynthesisOption"}], + "allOf": [{"$ref": "#/definitions/SynthesisOption"}], "properties": { "type": { "type": "number", @@ -81,7 +82,7 @@ } }, "choiceSynthesisOption": { - "allOf": [{"$ref": "#/definitions/generalSynthesisOption"}], + "allOf": [{"$ref": "#/definitions/SynthesisOption"}], "properties": { "type": { "type": "number", @@ -99,7 +100,7 @@ } }, "rangeSynthesisOption": { - "allOf": [{"$ref": "#/definitions/generalSynthesisOption"}], + "allOf": [{"$ref": "#/definitions/SynthesisOption"}], "properties": { "type": { "type": "number", @@ -125,7 +126,7 @@ } }, "textSynthesisOption": { - "allOf": [{"$ref": "#/definitions/generalSynthesisOption"}], + "allOf": [{"$ref": "#/definitions/SynthesisOption"}], "properties": { "type": { "type": "number", @@ -137,7 +138,7 @@ } }, "separatorSynthesisOption": { - "allOf": [{"$ref": "#/definitions/generalSynthesisOption"}], + "allOf": [{"$ref": "#/definitions/SynthesisOption"}], "properties": { "type": { "type": "number", @@ -146,11 +147,14 @@ } }, "categorySynthesisOption": { - "allOf": [{"$ref": "#/definitions/generalSynthesisOption"}], + "allOf": [{"$ref": "#/definitions/SynthesisOption"}], "properties": { "type": { "type": "number", "enum": [5] + }, + "initialValue": { + "type": "boolean" } } } diff --git a/schema/sprotty/actions/action.json b/schema/sprotty/actions/action.json new file mode 100644 index 00000000..48f6c51b --- /dev/null +++ b/schema/sprotty/actions/action.json @@ -0,0 +1,11 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "action", + "type": "object", + "properties": { + "kind": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/schema/sprotty/actions/requestBounds.json b/schema/sprotty/actions/requestBounds.json index d65e8c52..8eb97ad9 100644 --- a/schema/sprotty/actions/requestBounds.json +++ b/schema/sprotty/actions/requestBounds.json @@ -1,9 +1,9 @@ { - "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/messages/requestBounds.json", + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/actions/requestBounds.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "requestBounds", "type": "object", - "allOf": [{"$ref": "../../sprotty/messages/diagramAccept.json#/definitions/action"}], + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], "properties": { "kind": { "type": "string", @@ -25,7 +25,7 @@ "children": { "type": "array", "items": { - "$ref": "../../klighd/SKGraphSchema#/definitions/SKGraph" + "$ref": "/kieler/klighd-vscode/tree/main/schema/klighd/SKGraphSchema#/definitions/SKGraph" } } } diff --git a/schema/sprotty/actions/requestModel.json b/schema/sprotty/actions/requestModel.json new file mode 100644 index 00000000..f9e1564f --- /dev/null +++ b/schema/sprotty/actions/requestModel.json @@ -0,0 +1,34 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/actions/requestModel.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "requestBounds", + "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], + "properties": { + "kind": { + "type": "string", + "enum": ["requestModel"] + }, + "options": { + "type": "object", + "properties": { + "needsClientLayout": { + "type": "boolean" + }, + "needsServerLayout": { + "type": "boolean" + }, + "sourceUri": { + "type": "string" + }, + "diagramType": { + "type": "string", + "enum": ["keith-diagram"] + } + } + }, + "requestId": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/schema/sprotty/diagramAccept.json b/schema/sprotty/diagramAccept.json new file mode 100644 index 00000000..22a7b106 --- /dev/null +++ b/schema/sprotty/diagramAccept.json @@ -0,0 +1,27 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/messages/diagramAccept.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "diagram/accept", + "type": "object", + "properties": { + "jsonrpc": { + "type": "string" + }, + "method": { + "type": "string", + "enum": ["diagram/accept"] + }, + "params": { + "type": "object", + "properties": { + "clientId": { + "type": "string", + "enum": ["sprotty"] + }, + "action": { + "$ref": "./actions/action.json#action" + } + } + } + } +} \ No newline at end of file diff --git a/schema/sprotty/messages/diagramAccept.json b/schema/sprotty/messages/diagramAccept.json deleted file mode 100644 index b8fb5b86..00000000 --- a/schema/sprotty/messages/diagramAccept.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/messages/diagramAccept.json", - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "diagram/accept", - "type": "object", - "properties": { - "jsonrpc": { - "type": "string" - }, - "method": { - "type": "string", - "enum": ["diagram/accept"] - }, - "params": { - "type": "object", - "properties": { - "clientId": { - "type": "string", - "enum": ["sprotty"] - }, - "action": { - "$ref": "#/definitions/action" - } - } - } - }, - "definitions": { - "action": { - "type": "object", - "properties": { - "kind": { - "type": "string" - } - } - }, - "requestModelAction": { - "allOf": [{"$ref": "#/definitions/action"}], - "properties": { - "kind": { - "type": "string", - "enum": ["requestModel"] - }, - "options": { - "type": "object", - "properties": { - "needsClientLayout": { - "type": "boolean" - }, - "needsServerLayout": { - "type": "boolean" - }, - "sourceUri": { - "type": "string" - }, - "diagramType": { - "type": "string", - "enum": ["keith-diagram"] - } - } - }, - "requestId": { - "type": "string" - } - } - } - } -} \ No newline at end of file From 19dd1f1f8a8dc0801dfb7b5da217b504fbda8f38 Mon Sep 17 00:00:00 2001 From: Max Kasperowski Date: Wed, 9 Oct 2024 15:52:38 +0200 Subject: [PATCH 06/23] update schema structure --- schema/sprotty/diagramAccept.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/sprotty/diagramAccept.json b/schema/sprotty/diagramAccept.json index 22a7b106..8af36a81 100644 --- a/schema/sprotty/diagramAccept.json +++ b/schema/sprotty/diagramAccept.json @@ -19,7 +19,7 @@ "enum": ["sprotty"] }, "action": { - "$ref": "./actions/action.json#action" + "$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json" } } } From 48c49dbd76a506b2fc648a8318841e747659df48 Mon Sep 17 00:00:00 2001 From: Max Kasperowski Date: Thu, 10 Oct 2024 10:02:41 +0200 Subject: [PATCH 07/23] update schemas with required fields and add lsp message types --- schema/klighd/SKGraphSchema.json | 7 ++++ schema/klighd/actions/setSyntheses.json | 2 + schema/klighd/actions/updateOptions.json | 9 +++- schema/klighd/messages/setPreferences.json | 7 ++-- schema/lsp/initialize.json | 9 +--- schema/lsp/message.json | 13 ++++++ schema/lsp/requestMessage.json | 19 +++++++++ schema/lsp/responseMessage.json | 15 +++++++ schema/sprotty/actions/action.json | 1 + schema/sprotty/actions/requestBounds.json | 21 +--------- schema/sprotty/actions/requestModel.json | 49 +++++++++++----------- schema/sprotty/diagramAccept.json | 7 ++-- 12 files changed, 99 insertions(+), 60 deletions(-) create mode 100644 schema/lsp/message.json create mode 100644 schema/lsp/requestMessage.json create mode 100644 schema/lsp/responseMessage.json diff --git a/schema/klighd/SKGraphSchema.json b/schema/klighd/SKGraphSchema.json index 5305f351..8e38b258 100644 --- a/schema/klighd/SKGraphSchema.json +++ b/schema/klighd/SKGraphSchema.json @@ -3,6 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "SKElement", "type": "object", + "required": ["data", "properties", "type"], "properties": { "data": { "type": "array", @@ -24,6 +25,7 @@ "definitions": { "SModelElement": { "type": "object", + "required": ["type", "id", "children"], "properties": { "type": { "type": "string" @@ -47,6 +49,7 @@ }, "SShapeElement": { "allOf": [{"$ref": "#/definitions/SModelElement"}], + "required": ["size"], "properties": { "size": { "type": "object", @@ -65,6 +68,7 @@ }, "SKGraph": { "allOf": [{"$ref": "#"}, {"$ref": "#/definitions/SModelElement"}], + "required": ["type", "revision"], "properties": { "type": { "type": "string", @@ -77,6 +81,7 @@ }, "SKNode": { "allOf": [{"$ref": "#"}, {"$ref": "#/definitions/SShapeElement"}], + "required": ["type"], "properties": { "type": { "type": "string", @@ -86,6 +91,7 @@ }, "SKLabel": { "allOf": [{"$ref": "#"}, {"$ref": "#/definitions/SModelElement"}], + "required": ["type", "text"], "properties": { "text": { "type": "string" @@ -98,6 +104,7 @@ }, "SKEdge": { "allOf": [{"$ref": "#"}, {"$ref": "#/definitions/SModelElement"}], + "required": ["type", "sourceId", "targetId"], "properties": { "sourceId": { "type": "string" diff --git a/schema/klighd/actions/setSyntheses.json b/schema/klighd/actions/setSyntheses.json index 021faf00..37aae4a3 100644 --- a/schema/klighd/actions/setSyntheses.json +++ b/schema/klighd/actions/setSyntheses.json @@ -4,6 +4,7 @@ "title": "setSyntheses", "type": "object", "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "required": ["kind", "syntheses"], "properties": { "kind": { "type": "string", @@ -19,6 +20,7 @@ "definitions": { "synthesis": { "type": "object", + "required": ["id", "displayName"], "properties": { "id": { "type": "string" diff --git a/schema/klighd/actions/updateOptions.json b/schema/klighd/actions/updateOptions.json index 3a2b6f39..b570d319 100644 --- a/schema/klighd/actions/updateOptions.json +++ b/schema/klighd/actions/updateOptions.json @@ -4,6 +4,7 @@ "title": "updateOptions", "type": "object", "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "required": ["kind", "valuedSynthesisOptions", "layoutOptions", "actions", "modelUri"], "properties": { "kind": { "type": "string", @@ -28,6 +29,7 @@ "definitions": { "ValuedSynthesisOption": { "type": "object", + "required": ["synthesisOption", "currentValue"], "properties": { "synthesisOption": { "anyOf": [ @@ -46,8 +48,8 @@ }, "SynthesisOption": { "type": "object", + "required": ["id", "name", "type", "sourceHash", "initialValue"], "properties": { - "id": { "type": "string" }, @@ -55,7 +57,8 @@ "type": "string" }, "type": { - "type": "number" + "type": "number", + "enum": [0, 1, 2, 3, 4, 5] }, "updateAction": { "type": "string" @@ -83,6 +86,7 @@ }, "choiceSynthesisOption": { "allOf": [{"$ref": "#/definitions/SynthesisOption"}], + "required": ["values"], "properties": { "type": { "type": "number", @@ -101,6 +105,7 @@ }, "rangeSynthesisOption": { "allOf": [{"$ref": "#/definitions/SynthesisOption"}], + "required": ["range", "stepSize"], "properties": { "type": { "type": "number", diff --git a/schema/klighd/messages/setPreferences.json b/schema/klighd/messages/setPreferences.json index 75a37b7a..75c6b943 100644 --- a/schema/klighd/messages/setPreferences.json +++ b/schema/klighd/messages/setPreferences.json @@ -2,17 +2,16 @@ "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/messages/setPreferences.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "keith/preferences/setPreferences", - "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/requestMessage.json"}], + "required": ["method", "params"], "properties": { - "jsonrpc": { - "type": "string" - }, "method": { "type": "string", "enum": ["keith/preferences/setPreferences"] }, "params": { "type": "object", + "required": ["diagram.shouldSelectDiagram", "diagram.shouldSelectText", "diagram.incrementalDiagramGenerator"], "properties": { "diagram.shouldSelectDiagram": { "type": "boolean" diff --git a/schema/lsp/initialize.json b/schema/lsp/initialize.json index 8d9f2e8d..ae7b5766 100644 --- a/schema/lsp/initialize.json +++ b/schema/lsp/initialize.json @@ -2,14 +2,9 @@ "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/lsp/initialize.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "initialize", - "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/lsp/requestMessage.json"}], + "required": ["method", "params"], "properties": { - "jsonrpc": { - "type": "string" - }, - "id": { - "type": "number" - }, "method": { "type": "string", "enum": ["initialize"] diff --git a/schema/lsp/message.json b/schema/lsp/message.json new file mode 100644 index 00000000..ef38af37 --- /dev/null +++ b/schema/lsp/message.json @@ -0,0 +1,13 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/lsp/message.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "message", + "type": "object", + "required": ["jsonrpc"], + "properties": { + "jsonrpc": { + "type": "string", + "enum": ["2.0"] + } + } +} \ No newline at end of file diff --git a/schema/lsp/requestMessage.json b/schema/lsp/requestMessage.json new file mode 100644 index 00000000..1fa41a01 --- /dev/null +++ b/schema/lsp/requestMessage.json @@ -0,0 +1,19 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/lsp/requestmessage.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "message", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/lsp/message.json"}], + "required": ["id", "method"], + "properties": { + "id": { + "type": ["number", "string"] + }, + "method": { + "type": "string", + "enum": ["requestMessage"] + }, + "params": { + "type": ["array", "object"] + } + } +} \ No newline at end of file diff --git a/schema/lsp/responseMessage.json b/schema/lsp/responseMessage.json new file mode 100644 index 00000000..48db567e --- /dev/null +++ b/schema/lsp/responseMessage.json @@ -0,0 +1,15 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/lsp/requestmessage.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "message", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/lsp/message.json"}], + "required": ["id"], + "oneOf": [{"required": ["result"]}, {"required": ["error"]}], + "properties": { + "id": { + "type": ["number", "string", "null"] + }, + "result": {}, + "error": {} + } +} \ No newline at end of file diff --git a/schema/sprotty/actions/action.json b/schema/sprotty/actions/action.json index 48f6c51b..067295b0 100644 --- a/schema/sprotty/actions/action.json +++ b/schema/sprotty/actions/action.json @@ -3,6 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "action", "type": "object", + "required": ["kind"], "properties": { "kind": { "type": "string" diff --git a/schema/sprotty/actions/requestBounds.json b/schema/sprotty/actions/requestBounds.json index 8eb97ad9..9ad3dd50 100644 --- a/schema/sprotty/actions/requestBounds.json +++ b/schema/sprotty/actions/requestBounds.json @@ -4,31 +4,14 @@ "title": "requestBounds", "type": "object", "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], + "required": ["kind", "newRoot"], "properties": { "kind": { "type": "string", "enum": ["requestBounds"] }, "newRoot": { - "type": "object", - "properties": { - "properties": {}, - "revision": { - "type": "number" - }, - "type": { - "type": "string" - }, - "id": { - "type": "string" - }, - "children": { - "type": "array", - "items": { - "$ref": "/kieler/klighd-vscode/tree/main/schema/klighd/SKGraphSchema#/definitions/SKGraph" - } - } - } + "$ref": "/kieler/klighd-vscode/tree/main/schema/klighd/SKGraphSchema#/definitions/SKGraph" } } } \ No newline at end of file diff --git a/schema/sprotty/actions/requestModel.json b/schema/sprotty/actions/requestModel.json index f9e1564f..1aebcb5b 100644 --- a/schema/sprotty/actions/requestModel.json +++ b/schema/sprotty/actions/requestModel.json @@ -4,31 +4,32 @@ "title": "requestBounds", "type": "object", "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], - "properties": { - "kind": { - "type": "string", - "enum": ["requestModel"] - }, - "options": { - "type": "object", - "properties": { - "needsClientLayout": { - "type": "boolean" - }, - "needsServerLayout": { - "type": "boolean" - }, - "sourceUri": { - "type": "string" - }, - "diagramType": { - "type": "string", - "enum": ["keith-diagram"] - } + "required": ["kind", "options", "requestId"], + "properties": { + "kind": { + "type": "string", + "enum": ["requestModel"] + }, + "options": { + "type": "object", + "properties": { + "needsClientLayout": { + "type": "boolean" + }, + "needsServerLayout": { + "type": "boolean" + }, + "sourceUri": { + "type": "string" + }, + "diagramType": { + "type": "string", + "enum": ["keith-diagram"] } - }, - "requestId": { - "type": "string" } + }, + "requestId": { + "type": "string" } + } } \ No newline at end of file diff --git a/schema/sprotty/diagramAccept.json b/schema/sprotty/diagramAccept.json index 8af36a81..531bb740 100644 --- a/schema/sprotty/diagramAccept.json +++ b/schema/sprotty/diagramAccept.json @@ -2,17 +2,16 @@ "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/messages/diagramAccept.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "diagram/accept", - "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/requestMessage.json"}], + "required": ["method", "params"], "properties": { - "jsonrpc": { - "type": "string" - }, "method": { "type": "string", "enum": ["diagram/accept"] }, "params": { "type": "object", + "required": ["clientId", "action"], "properties": { "clientId": { "type": "string", From 402df1a50d04a4e91b02855979a9f239c9884a8a Mon Sep 17 00:00:00 2001 From: Max Kasperowski Date: Thu, 10 Oct 2024 11:36:24 +0200 Subject: [PATCH 08/23] additional actions and messages --- schema/klighd/SKGraphSchema.json | 24 +++ schema/klighd/ValuedSynthesisOption.json | 141 +++++++++++++++++ schema/klighd/actions/checkImages.json | 34 +++++ schema/klighd/actions/checkedImages.json | 37 +++++ schema/klighd/actions/performAction.json | 26 ++++ schema/klighd/actions/refreshDiagram.json | 14 ++ schema/klighd/actions/refreshLayout.json | 14 ++ .../klighd/actions/requestDiagramPiece.json | 17 +++ schema/klighd/actions/setDiagramPiece.json | 17 +++ schema/klighd/actions/setSynthesis.json | 17 +++ schema/klighd/actions/storeImages.json | 27 ++++ schema/klighd/actions/updateOptions.json | 142 +----------------- .../messages/diagramOptionsPerformAction.json | 25 +++ .../diagramOptionsSetLayoutOptions.json | 35 +++++ .../diagramOptionsSetSynthesisOptions.json | 28 ++++ ...es.json => preferencesSetPreferences.json} | 2 +- schema/lsp/generalSendMessage.json | 19 +++ schema/lsp/range.json | 29 ++++ schema/lsp/requestMessage.json | 2 +- schema/lsp/textDocumentDocumentHighlight.json | 29 ++++ schema/sprotty/actions/action.json | 3 + schema/sprotty/actions/allSelected.json | 17 +++ schema/sprotty/actions/elementSelected.json | 29 ++++ schema/sprotty/actions/fit.json | 26 ++++ schema/sprotty/actions/setModel.json | 17 +++ schema/sprotty/actions/updateModel.json | 17 +++ schema/sprotty/diagramOpenInTextEditor.json | 39 +++++ 27 files changed, 685 insertions(+), 142 deletions(-) create mode 100644 schema/klighd/ValuedSynthesisOption.json create mode 100644 schema/klighd/actions/checkImages.json create mode 100644 schema/klighd/actions/checkedImages.json create mode 100644 schema/klighd/actions/performAction.json create mode 100644 schema/klighd/actions/refreshDiagram.json create mode 100644 schema/klighd/actions/refreshLayout.json create mode 100644 schema/klighd/actions/requestDiagramPiece.json create mode 100644 schema/klighd/actions/setDiagramPiece.json create mode 100644 schema/klighd/actions/setSynthesis.json create mode 100644 schema/klighd/actions/storeImages.json create mode 100644 schema/klighd/messages/diagramOptionsPerformAction.json create mode 100644 schema/klighd/messages/diagramOptionsSetLayoutOptions.json create mode 100644 schema/klighd/messages/diagramOptionsSetSynthesisOptions.json rename schema/klighd/messages/{setPreferences.json => preferencesSetPreferences.json} (94%) create mode 100644 schema/lsp/generalSendMessage.json create mode 100644 schema/lsp/range.json create mode 100644 schema/lsp/textDocumentDocumentHighlight.json create mode 100644 schema/sprotty/actions/allSelected.json create mode 100644 schema/sprotty/actions/elementSelected.json create mode 100644 schema/sprotty/actions/fit.json create mode 100644 schema/sprotty/actions/setModel.json create mode 100644 schema/sprotty/actions/updateModel.json create mode 100644 schema/sprotty/diagramOpenInTextEditor.json diff --git a/schema/klighd/SKGraphSchema.json b/schema/klighd/SKGraphSchema.json index 8e38b258..fb86effc 100644 --- a/schema/klighd/SKGraphSchema.json +++ b/schema/klighd/SKGraphSchema.json @@ -62,6 +62,18 @@ } }, "default": { "width": 0.0, "height": 0.0 } + }, + "position": { + "type": "object", + "properties": { + "x": { + "type": "number" + }, + "y": { + "type": "number" + } + }, + "default": { "x": 0.0, "y": 0.0 } } } @@ -76,6 +88,18 @@ }, "revision": { "type": "number" + }, + "children": { + "type": "array", + "required": ["items"], + "items": [ + { + "$ref": "#/definitions/SModelElement" + } + ], + "default": [], + "minItems": 1, + "maxItems": 1 } } }, diff --git a/schema/klighd/ValuedSynthesisOption.json b/schema/klighd/ValuedSynthesisOption.json new file mode 100644 index 00000000..b5705837 --- /dev/null +++ b/schema/klighd/ValuedSynthesisOption.json @@ -0,0 +1,141 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/ValuedSynthesisOption.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ValuedSynthesisOption", + "type": "object", + "required": ["synthesisOption", "currentValue"], + "properties": { + "synthesisOption": { + "anyOf": [ + {"$ref": "#/definitions/checkSynthesisOption"}, + {"$ref": "#/definitions/choiceSynthesisOption"}, + {"$ref": "#/definitions/rangeSynthesisOption"}, + {"$ref": "#/definitions/textSynthesisOption"}, + {"$ref": "#/definitions/separatorSynthesisOption"}, + {"$ref": "#/definitions/categorySynthesisOption"} + ] + }, + "currentValue": { + "type": ["string", "number", "boolean"] + } + }, + "definitions": { + "SynthesisOption": { + "type": "object", + "required": ["id", "name", "type", "sourceHash", "initialValue"], + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "type": { + "type": "number", + "enum": [0, 1, 2, 3, 4, 5] + }, + "updateAction": { + "type": "string" + }, + "category": { + "$ref": "#/definitions/categorySynthesisOption" + }, + "sourceHash": { + "type": "string" + }, + "initialValue": {} + } + }, + "checkSynthesisOption": { + "allOf": [{"$ref": "#/definitions/SynthesisOption"}], + "properties": { + "type": { + "type": "number", + "enum": [0] + }, + "initialValue": { + "type": "boolean" + } + } + }, + "choiceSynthesisOption": { + "allOf": [{"$ref": "#/definitions/SynthesisOption"}], + "required": ["values"], + "properties": { + "type": { + "type": "number", + "enum": [1] + }, + "initialValue": { + "type": "string" + }, + "values": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "rangeSynthesisOption": { + "allOf": [{"$ref": "#/definitions/SynthesisOption"}], + "required": ["range", "stepSize"], + "properties": { + "type": { + "type": "number", + "enum": [2] + }, + "initialValue": { + "type": "number" + }, + "range": { + "type": "object", + "properties": { + "first": { + "type": "number" + }, + "second": { + "type": "number" + } + } + }, + "stepSize": { + "type": "number" + } + } + }, + "textSynthesisOption": { + "allOf": [{"$ref": "#/definitions/SynthesisOption"}], + "properties": { + "type": { + "type": "number", + "enum": [3] + }, + "initialValue": { + "type": "string" + } + } + }, + "separatorSynthesisOption": { + "allOf": [{"$ref": "#/definitions/SynthesisOption"}], + "properties": { + "type": { + "type": "number", + "enum": [4] + } + } + }, + "categorySynthesisOption": { + "allOf": [{"$ref": "#/definitions/SynthesisOption"}], + "properties": { + "type": { + "type": "number", + "enum": [5] + }, + "initialValue": { + "type": "boolean" + } + } + } + } +} \ No newline at end of file diff --git a/schema/klighd/actions/checkImages.json b/schema/klighd/actions/checkImages.json new file mode 100644 index 00000000..c5c7006a --- /dev/null +++ b/schema/klighd/actions/checkImages.json @@ -0,0 +1,34 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/actions/checkImages.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "checkImages", + "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "required": ["kind", "images"], + "properties": { + "kind": { + "type": "string", + "enum": ["checkImages"] + }, + "images": { + "type": "array", + "items": { + "$ref": "#/definitions/image" + } + } + }, + "definitions": { + "image": { + "type": "object", + "required": ["bundleName", "imagePath"], + "properties": { + "bundleName": { + "type": "string" + }, + "imagePath": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/schema/klighd/actions/checkedImages.json b/schema/klighd/actions/checkedImages.json new file mode 100644 index 00000000..6e5445cc --- /dev/null +++ b/schema/klighd/actions/checkedImages.json @@ -0,0 +1,37 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/actions/checkedImages.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "checkedImages", + "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "required": ["kind", "notCached", "responseId"], + "properties": { + "kind": { + "type": "string", + "enum": ["checkedImages"] + }, + "notCached": { + "type": "array", + "items": { + "$ref": "#/definitions/notCachedImage" + } + }, + "responseId": { + "type": "string" + } + }, + "definitions": { + "notCachedImage": { + "type": "object", + "required": ["k", "v"], + "properties": { + "k": { + "type": "string" + }, + "v": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/schema/klighd/actions/performAction.json b/schema/klighd/actions/performAction.json new file mode 100644 index 00000000..0dfe923d --- /dev/null +++ b/schema/klighd/actions/performAction.json @@ -0,0 +1,26 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/actions/performAction.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "performAction", + "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], + "required": ["kind", "actionId", "kGraphElementId", "kRenderingId", "revision"], + "properties": { + "kind": { + "type": "string", + "enum": ["performAction"] + }, + "actionId": { + "type": "string" + }, + "kGraphElementId": { + "type": "string" + }, + "kRenderingId": { + "type": "string" + }, + "revision": { + "type": "number" + } + } +} \ No newline at end of file diff --git a/schema/klighd/actions/refreshDiagram.json b/schema/klighd/actions/refreshDiagram.json new file mode 100644 index 00000000..56fc6379 --- /dev/null +++ b/schema/klighd/actions/refreshDiagram.json @@ -0,0 +1,14 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/actions/refreshDiagram.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "refreshDiagram", + "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "required": ["kind"], + "properties": { + "kind": { + "type": "string", + "enum": ["refreshDiagram"] + } + } +} \ No newline at end of file diff --git a/schema/klighd/actions/refreshLayout.json b/schema/klighd/actions/refreshLayout.json new file mode 100644 index 00000000..0f322b89 --- /dev/null +++ b/schema/klighd/actions/refreshLayout.json @@ -0,0 +1,14 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/actions/refreshLayout.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "refreshLayout", + "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "required": ["kind"], + "properties": { + "kind": { + "type": "string", + "enum": ["refreshLayout"] + } + } +} \ No newline at end of file diff --git a/schema/klighd/actions/requestDiagramPiece.json b/schema/klighd/actions/requestDiagramPiece.json new file mode 100644 index 00000000..9d92c8eb --- /dev/null +++ b/schema/klighd/actions/requestDiagramPiece.json @@ -0,0 +1,17 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/actions/requestDiagramPiece.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "requestDiagramPiece", + "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "required": ["kind", "modelElementId"], + "properties": { + "kind": { + "type": "string", + "enum": ["requestDiagramPiece"] + }, + "modelElementId": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/schema/klighd/actions/setDiagramPiece.json b/schema/klighd/actions/setDiagramPiece.json new file mode 100644 index 00000000..b538bb30 --- /dev/null +++ b/schema/klighd/actions/setDiagramPiece.json @@ -0,0 +1,17 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/actions/setDiagramPiece.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "setDiagramPiece", + "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "required": ["kind", "diagramPiece"], + "properties": { + "kind": { + "type": "string", + "enum": ["setDiagramPiece"] + }, + "diagramPiece": { + "$ref": "/kieler/klighd-vscode/tree/main/schema/klighd/SKGraphSchema.json#/definitions/SKNode" + } + } +} \ No newline at end of file diff --git a/schema/klighd/actions/setSynthesis.json b/schema/klighd/actions/setSynthesis.json new file mode 100644 index 00000000..1cdc4d50 --- /dev/null +++ b/schema/klighd/actions/setSynthesis.json @@ -0,0 +1,17 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/actions/setSynthesis.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "setSynthesis", + "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "required": ["kind", "id"], + "properties": { + "kind": { + "type": "string", + "enum": ["setSynthesis"] + }, + "id": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/schema/klighd/actions/storeImages.json b/schema/klighd/actions/storeImages.json new file mode 100644 index 00000000..c58f4c66 --- /dev/null +++ b/schema/klighd/actions/storeImages.json @@ -0,0 +1,27 @@ + +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/actions/storeImages.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "storeImages", + "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "required": ["kind", "images"], + "properties": { + "kind": { + "type": "string", + "enum": ["storeImages"] + }, + "images": { + "type": "object", + "required": ["k", "v"], + "properties": { + "k": { + "$ref": "/kieler/klighd-vscode/tree/main/schema/klighd/actions/checkedImages.json#/definitions/notCachedImage" + }, + "v": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/schema/klighd/actions/updateOptions.json b/schema/klighd/actions/updateOptions.json index b570d319..8084bf9a 100644 --- a/schema/klighd/actions/updateOptions.json +++ b/schema/klighd/actions/updateOptions.json @@ -13,7 +13,7 @@ "valuedSynthesisOptions": { "type": "array", "items": { - "$ref": "#/definitions/ValuedSynthesisOption" + "$ref": "/kieler/klighd-vscode/tree/main/schema/klighd/valuedSynthesisOption.json" } }, "layoutOptions": { @@ -25,143 +25,5 @@ "modelUri": { "type": "string" } - }, - "definitions": { - "ValuedSynthesisOption": { - "type": "object", - "required": ["synthesisOption", "currentValue"], - "properties": { - "synthesisOption": { - "anyOf": [ - {"$ref": "#/definitions/checkSynthesisOption"}, - {"$ref": "#/definitions/choiceSynthesisOption"}, - {"$ref": "#/definitions/rangeSynthesisOption"}, - {"$ref": "#/definitions/textSynthesisOption"}, - {"$ref": "#/definitions/separatorSynthesisOption"}, - {"$ref": "#/definitions/categorySynthesisOption"} - ] - }, - "currentValue": { - "type": ["string", "number", "boolean"] - } - } - }, - "SynthesisOption": { - "type": "object", - "required": ["id", "name", "type", "sourceHash", "initialValue"], - "properties": { - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "type": { - "type": "number", - "enum": [0, 1, 2, 3, 4, 5] - }, - "updateAction": { - "type": "string" - }, - "category": { - "$ref": "#/definitions/categorySynthesisOption" - }, - "sourceHash": { - "type": "string" - }, - "initialValue": {} - } - }, - "checkSynthesisOption": { - "allOf": [{"$ref": "#/definitions/SynthesisOption"}], - "properties": { - "type": { - "type": "number", - "enum": [0] - }, - "initialValue": { - "type": "boolean" - } - } - }, - "choiceSynthesisOption": { - "allOf": [{"$ref": "#/definitions/SynthesisOption"}], - "required": ["values"], - "properties": { - "type": { - "type": "number", - "enum": [1] - }, - "initialValue": { - "type": "string" - }, - "values": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "rangeSynthesisOption": { - "allOf": [{"$ref": "#/definitions/SynthesisOption"}], - "required": ["range", "stepSize"], - "properties": { - "type": { - "type": "number", - "enum": [2] - }, - "initialValue": { - "type": "number" - }, - "range": { - "type": "object", - "properties": { - "first": { - "type": "number" - }, - "second": { - "type": "number" - } - } - }, - "stepSize": { - "type": "number" - } - } - }, - "textSynthesisOption": { - "allOf": [{"$ref": "#/definitions/SynthesisOption"}], - "properties": { - "type": { - "type": "number", - "enum": [3] - }, - "initialValue": { - "type": "string" - } - } - }, - "separatorSynthesisOption": { - "allOf": [{"$ref": "#/definitions/SynthesisOption"}], - "properties": { - "type": { - "type": "number", - "enum": [4] - } - } - }, - "categorySynthesisOption": { - "allOf": [{"$ref": "#/definitions/SynthesisOption"}], - "properties": { - "type": { - "type": "number", - "enum": [5] - }, - "initialValue": { - "type": "boolean" - } - } - } - } + } } \ No newline at end of file diff --git a/schema/klighd/messages/diagramOptionsPerformAction.json b/schema/klighd/messages/diagramOptionsPerformAction.json new file mode 100644 index 00000000..48628e22 --- /dev/null +++ b/schema/klighd/messages/diagramOptionsPerformAction.json @@ -0,0 +1,25 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/messages/diagramOptionsPerformAction.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "keith/diagramOptions/performAction", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/requestMessage.json"}], + "required": ["method", "params"], + "properties": { + "method": { + "type": "string", + "enum": ["keith/diagramOptions/performAction"] + }, + "params": { + "type": "object", + "required": ["actionId", "uri"], + "properties": { + "actionId": { + "type": "string" + }, + "uri": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/schema/klighd/messages/diagramOptionsSetLayoutOptions.json b/schema/klighd/messages/diagramOptionsSetLayoutOptions.json new file mode 100644 index 00000000..cacc7e8e --- /dev/null +++ b/schema/klighd/messages/diagramOptionsSetLayoutOptions.json @@ -0,0 +1,35 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/messages/diagramOptionsSetLayoutOptions.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "keith/diagramOptions/setLayoutOptions", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/requestMessage.json"}], + "required": ["method", "params"], + "properties": { + "method": { + "type": "string", + "enum": ["keith/diagramOptions/setLayoutOptions"] + }, + "params": { + "type": "object", + "required": ["layoutOptions", "uri"], + "properties": { + "layoutOptions": { + "type": "array", + "items": { + "type": "object", + "required": ["optionId", "value"], + "properties": { + "optionId": { + "type": "string" + }, + "value": {} + } + } + }, + "uri": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/schema/klighd/messages/diagramOptionsSetSynthesisOptions.json b/schema/klighd/messages/diagramOptionsSetSynthesisOptions.json new file mode 100644 index 00000000..6d60dae1 --- /dev/null +++ b/schema/klighd/messages/diagramOptionsSetSynthesisOptions.json @@ -0,0 +1,28 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/messages/diagramOptionsSetSynthesisOptions.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "keith/diagramOptions/setSynthesisOptions", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/requestMessage.json"}], + "required": ["method", "params"], + "properties": { + "method": { + "type": "string", + "enum": ["keith/diagramOptions/setSynthesisOptions"] + }, + "params": { + "type": "object", + "required": ["synthesisOptions"], + "properties": { + "synthesisOptions": { + "type": "array", + "items": { + "$ref": "/kieler/klighd-vscode/tree/main/schema/klighd/valuedSynthesisOption.json" + } + }, + "uri": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/schema/klighd/messages/setPreferences.json b/schema/klighd/messages/preferencesSetPreferences.json similarity index 94% rename from schema/klighd/messages/setPreferences.json rename to schema/klighd/messages/preferencesSetPreferences.json index 75c6b943..227f8265 100644 --- a/schema/klighd/messages/setPreferences.json +++ b/schema/klighd/messages/preferencesSetPreferences.json @@ -1,5 +1,5 @@ { - "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/messages/setPreferences.json", + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/messages/preferencesSetPreferences.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "keith/preferences/setPreferences", "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/requestMessage.json"}], diff --git a/schema/lsp/generalSendMessage.json b/schema/lsp/generalSendMessage.json new file mode 100644 index 00000000..6da08838 --- /dev/null +++ b/schema/lsp/generalSendMessage.json @@ -0,0 +1,19 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/lsp/generalSendMessage.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "general/sendMessage", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/lsp/requestMessage.json"}], + "required": ["method", "params"], + "properties": { + "method": { + "type": "string", + "enum": ["general/sendMessage"] + }, + "params": { + "type": "array", + "items": { + "type": "string" + } + } + } +} \ No newline at end of file diff --git a/schema/lsp/range.json b/schema/lsp/range.json new file mode 100644 index 00000000..47f7a90a --- /dev/null +++ b/schema/lsp/range.json @@ -0,0 +1,29 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/lsp/range.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "range", + "type": "object", + "required": ["start", "end"], + "properties": { + "start": { + "$ref": "#/definitions/editorPosition.json" + }, + "end": { + "$ref": "#/definitions/editorPosition.json" + } + }, + "definitions": { + "editorPosition.json": { + "type": "object", + "required": ["line", "character"], + "properties": { + "line": { + "type": "integer" + }, + "character": { + "type": "integer" + } + } + } + } +} \ No newline at end of file diff --git a/schema/lsp/requestMessage.json b/schema/lsp/requestMessage.json index 1fa41a01..03924db3 100644 --- a/schema/lsp/requestMessage.json +++ b/schema/lsp/requestMessage.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "message", "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/lsp/message.json"}], - "required": ["id", "method"], + "required": ["method"], "properties": { "id": { "type": ["number", "string"] diff --git a/schema/lsp/textDocumentDocumentHighlight.json b/schema/lsp/textDocumentDocumentHighlight.json new file mode 100644 index 00000000..998e3fbe --- /dev/null +++ b/schema/lsp/textDocumentDocumentHighlight.json @@ -0,0 +1,29 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/lsp/textDocumentDocumentHighlight.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "textDocument/documentHighlight", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/lsp/requestMessage.json"}], + "required": ["method", "params"], + "properties": { + "method": { + "type": "string", + "enum": ["textDocument/documentHighlight"] + }, + "params": { + "type": "object", + "properties": { + "textDocument": { + "type":"object", + "properties": { + "uri": { + "type": "string" + } + } + }, + "position": { + "$ref": "/kieler/klighd-vscode/tree/main/schema/lsp/position.json" + } + } + } + } +} \ No newline at end of file diff --git a/schema/sprotty/actions/action.json b/schema/sprotty/actions/action.json index 067295b0..2cb2fa92 100644 --- a/schema/sprotty/actions/action.json +++ b/schema/sprotty/actions/action.json @@ -7,6 +7,9 @@ "properties": { "kind": { "type": "string" + }, + "requestId": { + "type": "string" } } } \ No newline at end of file diff --git a/schema/sprotty/actions/allSelected.json b/schema/sprotty/actions/allSelected.json new file mode 100644 index 00000000..1214c45a --- /dev/null +++ b/schema/sprotty/actions/allSelected.json @@ -0,0 +1,17 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/actions/allSelected.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "allSelected", + "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], + "required": ["kind", "select"], + "properties": { + "kind": { + "type": "string", + "enum": ["allSelected"] + }, + "select": { + "type": "boolean" + } + } +} \ No newline at end of file diff --git a/schema/sprotty/actions/elementSelected.json b/schema/sprotty/actions/elementSelected.json new file mode 100644 index 00000000..f19c3619 --- /dev/null +++ b/schema/sprotty/actions/elementSelected.json @@ -0,0 +1,29 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/actions/elementSelected.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "elementSelected", + "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], + "required": ["kind", "selectedElementsIDs", "deselectedElementsIDs", "preventOpenSelection"], + "properties": { + "kind": { + "type": "string", + "enum": ["elementSelected"] + }, + "selectedElementsIDs": { + "type": "array", + "items": { + "type": "string" + } + }, + "deselectedElementsIDs": { + "type": "array", + "items": { + "type": "string" + } + }, + "preventOpenSelection": { + "type": "boolean" + } + } +} \ No newline at end of file diff --git a/schema/sprotty/actions/fit.json b/schema/sprotty/actions/fit.json new file mode 100644 index 00000000..9a82a5cf --- /dev/null +++ b/schema/sprotty/actions/fit.json @@ -0,0 +1,26 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/actions/fit.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "fit", + "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], + "required": ["kind", "elementIds", "maxZoom", "animate"], + "properties": { + "kind": { + "type": "string", + "enum": ["fit"] + }, + "elementIds": { + "type": "array", + "items": { + "type": "string" + } + }, + "maxZoom": { + "type": "number" + }, + "animate": { + "type": "boolean" + } + } +} \ No newline at end of file diff --git a/schema/sprotty/actions/setModel.json b/schema/sprotty/actions/setModel.json new file mode 100644 index 00000000..ff8d309d --- /dev/null +++ b/schema/sprotty/actions/setModel.json @@ -0,0 +1,17 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/actions/setModel.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "setModel", + "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], + "required": ["kind", "newRoot"], + "properties": { + "kind": { + "type": "string", + "enum": ["setModel"] + }, + "newRoot": { + "$ref": "/kieler/klighd-vscode/tree/main/schema/klighd/SKGraphSchema#/definitions/SKGraph" + } + } +} \ No newline at end of file diff --git a/schema/sprotty/actions/updateModel.json b/schema/sprotty/actions/updateModel.json new file mode 100644 index 00000000..a6c1a1b8 --- /dev/null +++ b/schema/sprotty/actions/updateModel.json @@ -0,0 +1,17 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/actions/updateModel.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "updateModel", + "type": "object", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], + "required": ["kind", "newRoot"], + "properties": { + "kind": { + "type": "string", + "enum": ["updateModel"] + }, + "newRoot": { + "$ref": "/kieler/klighd-vscode/tree/main/schema/klighd/SKGraphSchema#/definitions/SKGraph" + } + } +} \ No newline at end of file diff --git a/schema/sprotty/diagramOpenInTextEditor.json b/schema/sprotty/diagramOpenInTextEditor.json new file mode 100644 index 00000000..0be1cbd9 --- /dev/null +++ b/schema/sprotty/diagramOpenInTextEditor.json @@ -0,0 +1,39 @@ +{ + "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/messages/diagramOpenInTextEditor.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "diagram/openInTextEditor", + "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/requestMessage.json"}], + "required": ["method", "params"], + "properties": { + "method": { + "type": "string", + "enum": ["diagram/openInTextEditor"] + }, + "params": { + "type": "object", + "required": ["location", "forceOpen"], + "properties": { + "location": { + "$ref": "#/definitions/location" + }, + "forceOpen": { + "type": "boolean" + } + } + } + }, + "definitions": { + "location": { + "type": "object", + "required": ["uri", "range"], + "properties": { + "uri": { + "type": "string" + }, + "range": { + "$ref": "/kieler/klighd-vscode/tree/main/schema/lsp/range.json" + } + } + } + } +} \ No newline at end of file From 046b0e77fc225c8697594f2aaaf992ba8e00a0ef Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Fri, 18 Oct 2024 14:03:08 +0200 Subject: [PATCH 09/23] removed working options from blacklist. These options work. I need them. So they finally get reactivated! --- packages/klighd-core/src/options/options-blacklist.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/klighd-core/src/options/options-blacklist.ts b/packages/klighd-core/src/options/options-blacklist.ts index 20bf56c3..571cc3ac 100644 --- a/packages/klighd-core/src/options/options-blacklist.ts +++ b/packages/klighd-core/src/options/options-blacklist.ts @@ -3,7 +3,7 @@ * * http://rtsys.informatik.uni-kiel.de/kieler * - * Copyright 2021 by + * Copyright 2021-2024 by * + Kiel University * + Department of Computer Science * + Real-Time and Embedded Systems Group @@ -23,11 +23,6 @@ // - Editor Context Collapse (getContextViewer in SprottyViewer not yet implemented) // - SCG Dependencies (?) // - Turning off KlayLayered (Pops up a new window in KIELER to specify the algorithm path) de.cau.cs.kieler.sccharts.ui.synthesis.GeneralSynthesisOptions.CHECK-857562601 -// - Label Management does nothing de.cau.cs.kieler.sccharts.ui.synthesis.hooks.LabelShorteningHook.CHOICE2065322287 -// KGraph text: -// - Suppress Edge Adjustments de.cau.cs.kieler.graphs.klighd.syntheses.KGraphDiagramSynthesis.CHECK-1675366116 -// - Label shortening Strategy (Probably label manager) de.cau.cs.kieler.graphs.klighd.syntheses.AbstractStyledDiagramSynthesis.CHOICE577556810 -// - Shortening width de.cau.cs.kieler.sccharts.ui.synthesis.hooks.LabelShorteningHook.RANGE-230395005 // SCG: // - Show only dependencies of selected elements (because selection is not yet implemented to be transferred to klighd) // de.cau.cs.kieler.scg.klighd.SCGraphSynthesisOptions.CHECK-496527882 @@ -50,8 +45,6 @@ export const optionsBlacklist = [ 'de.cau.cs.kieler.sccharts.ui.synthesis.hooks.ExpandCollapseHook.CHECK-1902441701', 'de.cau.cs.kieler.sccharts.ui.synthesis.AdaptiveZoom.CHECK-1237943491', 'de.cau.cs.kieler.sccharts.ui.synthesis.GeneralSynthesisOptions.CHECK-857562601', - 'de.cau.cs.kieler.graphs.klighd.syntheses.KGraphDiagramSynthesis.CHECK-1675366116', - 'de.cau.cs.kieler.graphs.klighd.syntheses.AbstractStyledDiagramSynthesis.CHOICE577556810', 'de.cau.cs.kieler.scg.klighd.SCGraphSynthesisOptions.CHECK-496527882', 'de.cau.cs.kieler.scg.klighd.SCGraphSynthesisOptions.CHECK-1237943491', 'de.cau.cs.kieler.scg.klighd.actions.ThreadPriorityActions.CHECK1258957970', From c4ac7b26a654c5fcd08f73e7bdfc36b4fad5bf33 Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Tue, 22 Oct 2024 17:18:19 +0200 Subject: [PATCH 10/23] for production (build/package), do not use source maps, during development (watch), use the correct ones to make webview and extension debuggable. --- applications/klighd-vscode/package.json | 4 ++-- applications/klighd-vscode/webpack.config.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/applications/klighd-vscode/package.json b/applications/klighd-vscode/package.json index 24686502..9f8c592e 100644 --- a/applications/klighd-vscode/package.json +++ b/applications/klighd-vscode/package.json @@ -152,8 +152,8 @@ "scripts": { "clean": "rimraf dist klighd-vscode.vsix", "lint": "eslint .", - "build": "webpack --mode development --devtool eval-source-map", - "watch": "webpack --watch --mode development --devtool eval-source-map", + "build": "webpack --mode production --devtool false", + "watch": "webpack --watch --mode development", "package": "vsce package --yarn --baseImagesUrl https://github.com/kieler/klighd-vscode/raw/HEAD/applications/klighd-vscode -o klighd-vscode.vsix", "predistribute": "yarn run package", "distribute": "yarn run distribute:vsce && yarn run distribute:ovsx", diff --git a/applications/klighd-vscode/webpack.config.js b/applications/klighd-vscode/webpack.config.js index df7447bb..6d09c8a0 100644 --- a/applications/klighd-vscode/webpack.config.js +++ b/applications/klighd-vscode/webpack.config.js @@ -86,7 +86,7 @@ const webviewConfig = { filename: "webview.js", path: path.resolve(__dirname, "pack"), }, - devtool: "nosources-source-map", + devtool: "eval-source-map", resolve: { extensions: [".ts", ".js"], From 1e80ab3f758052e22150a7776cc41be7e844e4cf Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Tue, 22 Oct 2024 19:49:22 +0200 Subject: [PATCH 11/23] Removes the double diagram request on opening VS Code with no editor in focus During adoption to Sprotty 0.13 another way of updating the diagram was introduced that always requests a diagram when the editor is switched. When opening VS Code now with no editor in focus (e.g. when the diagram was in focus, which is not re-opened by VS Code by default), clicking on an editor triggered this newly introduced switch AND this now-removed code we had for exactly that use case. As this is now superfluous and causes duplicated requests, this removes that issue. --- .../klighd-vscode/src/klighd-webview-reopener.ts | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/applications/klighd-vscode/src/klighd-webview-reopener.ts b/applications/klighd-vscode/src/klighd-webview-reopener.ts index 4e482370..d5c9a3d9 100644 --- a/applications/klighd-vscode/src/klighd-webview-reopener.ts +++ b/applications/klighd-vscode/src/klighd-webview-reopener.ts @@ -3,7 +3,7 @@ * * http://rtsys.informatik.uni-kiel.de/kieler * - * Copyright 2022-2023 by + * Copyright 2022-2024 by * + Kiel University * + Department of Computer Science * + Real-Time and Embedded Systems Group @@ -35,19 +35,6 @@ export class KlighdWebviewReopener { if (activeTextEditor) { const uri = activeTextEditor.document.fileName commands.executeCommand(command.diagramOpen, Uri.file(uri)) - } else { - // Register this an active editor changed to open the diagram then. - this.toDispose.push( - window.onDidChangeActiveTextEditor((editor) => { - let uri - if (editor) { - uri = editor.document.uri - } - commands.executeCommand(command.diagramOpen, uri) - // Remove listener again - this.toDispose.forEach((element) => element.dispose()) - }) - ) } } } From c848768e04714c97fd8a14daa3c4a360b98c7048 Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Tue, 5 Nov 2024 14:55:14 +0100 Subject: [PATCH 12/23] implement new preference to change between client and server layout --- packages/klighd-core/src/di.config.ts | 6 ++-- packages/klighd-core/src/diagram-server.ts | 22 ++++++++++++-- .../klighd-core/src/options/general-panel.tsx | 20 +++++++++++++ .../src/options/render-options-registry.ts | 4 +-- .../klighd-core/src/preferences-registry.ts | 29 ++++++++++++++++++- packages/klighd-interactive/src/actions.ts | 8 +++-- schema/klighd/actions/refreshDiagram.json | 15 ++++++++-- .../messages/preferencesSetPreferences.json | 3 ++ schema/sprotty/actions/requestModel.json | 6 ++-- 9 files changed, 96 insertions(+), 17 deletions(-) diff --git a/packages/klighd-core/src/di.config.ts b/packages/klighd-core/src/di.config.ts index 1f62a620..3de3d0d7 100644 --- a/packages/klighd-core/src/di.config.ts +++ b/packages/klighd-core/src/di.config.ts @@ -160,9 +160,9 @@ export default function createContainer(widgetId: string): Container { ) // FIXME: bookmarkModule is currently broken due to wrong usage of Sprotty commands. action handling needs to be reimplemented for this to work. overrideViewerOptions(container, { - // TODO: need some configuration switch to enable/disable client layout - needsClientLayout: true, // client layout = micro layout (Sprotty/Sprotty+KLighD) - needsServerLayout: false, // server layout = macro layout (ELK/elkjs). false here to not forward it to the Java server (the model source), but keep and handle it directly on the diagram server proxy manually + // These are ignored ignored and overwritten by the current needsClientLayout preference during model request. + needsClientLayout: false, // client layout = micro layout (Sprotty/Sprotty+KLighD) + needsServerLayout: true, // server layout = macro layout (ELK/elkjs). false here to not forward it to the Java server (the model source), but keep and handle it directly on the diagram server proxy manually baseDiv: widgetId, hiddenDiv: `${widgetId}_hidden`, // TODO: We should be able to completely deactivate Sprotty's zoom limits to not limit top down layout. diff --git a/packages/klighd-core/src/diagram-server.ts b/packages/klighd-core/src/diagram-server.ts index 4796f2a0..78c6325f 100644 --- a/packages/klighd-core/src/diagram-server.ts +++ b/packages/klighd-core/src/diagram-server.ts @@ -84,7 +84,7 @@ import { import { RequestKlighdPopupModelAction } from './hover/hover' import { PopupModelProvider } from './hover/popup-provider' import { RenderOptionsRegistry, ResizeToFit } from './options/render-options-registry' -import { IncrementalDiagramGeneratorOption, PreferencesRegistry } from './preferences-registry' +import { ClientLayoutOption, IncrementalDiagramGeneratorOption, PreferencesRegistry } from './preferences-registry' import { Connection, ServiceTypes, SessionStorage } from './services' import { SetSynthesisAction } from './syntheses/actions' import { UpdateDepthMapModelAction } from './update/update-depthmap-model' @@ -308,9 +308,27 @@ export class KlighdDiagramServer extends DiagramServerProxy { return false } + // Super class behavior, except taking the needsClientLayout preference into account instead of the client option. + override handleRequestModel(action: RequestModelAction): boolean { + const needsClientLayout = !!this.preferencesRegistry.getValue(ClientLayoutOption) + const needsServerLayout = !needsClientLayout + + const newOptions = { + needsClientLayout, + needsServerLayout, + ...action.options, + } + const newAction = { + ...action, + options: newOptions, + } + this.forwardToServer(newAction) + return false + } + // Behavior adapted from the super class and modified to the behavior of the DiagramServer to allow this proxy to the Java diagram server to still be able to perform the layout locally. handleComputedBounds(action: ComputedBoundsAction): boolean { - if (this.viewerOptions.needsServerLayout) { + if (!this.preferencesRegistry.getValue(ClientLayoutOption)) { return false } const root = this.currentRoot diff --git a/packages/klighd-core/src/options/general-panel.tsx b/packages/klighd-core/src/options/general-panel.tsx index 6372dbea..89112042 100644 --- a/packages/klighd-core/src/options/general-panel.tsx +++ b/packages/klighd-core/src/options/general-panel.tsx @@ -19,9 +19,11 @@ import { inject, injectable, postConstruct } from 'inversify' import { VNode } from 'snabbdom' import { html } from 'sprotty' // eslint-disable-line @typescript-eslint/no-unused-vars +import { RefreshDiagramAction } from '@kieler/klighd-interactive/lib/actions' import { DISymbol } from '../di.symbols' import { FeatherIcon } from '../feather-icons-snabbdom/feather-icons-snabbdom' import { + ClientLayoutOption, IncrementalDiagramGeneratorOption, PreferencesRegistry, ShouldSelectDiagramOption, @@ -123,6 +125,16 @@ export class GeneralPanel extends SidebarPanel { ) : ( '' )} + {(this.renderOptionsRegistry.getValue(DebugOptions) as boolean) ? ( + + ) : ( + '' + )} ) @@ -134,6 +146,14 @@ export class GeneralPanel extends SidebarPanel { private handlePreferenceChange(key: string, newValue: any) { this.actionDispatcher.dispatch(SetPreferencesAction.create([{ id: key, value: newValue }])) + if (key === ClientLayoutOption.ID) { + this.actionDispatcher.dispatch( + RefreshDiagramAction.create({ + needsClientLayout: newValue, + needsServerLayout: !newValue, + }) + ) + } } get icon(): VNode { diff --git a/packages/klighd-core/src/options/render-options-registry.ts b/packages/klighd-core/src/options/render-options-registry.ts index 07d7fdc9..77c6f3d2 100644 --- a/packages/klighd-core/src/options/render-options-registry.ts +++ b/packages/klighd-core/src/options/render-options-registry.ts @@ -3,7 +3,7 @@ * * http://rtsys.informatik.uni-kiel.de/kieler * - * Copyright 2021-2022 by + * Copyright 2021-2024 by * + Kiel University * + Department of Computer Science * + Real-Time and Embedded Systems Group @@ -509,8 +509,6 @@ export class DebugOptions implements RenderOption { readonly description = 'Whether debug options should be shown.' currentValue = false - - debug = true } export interface RenderOptionType { diff --git a/packages/klighd-core/src/preferences-registry.ts b/packages/klighd-core/src/preferences-registry.ts index 280681b2..fdb446a1 100644 --- a/packages/klighd-core/src/preferences-registry.ts +++ b/packages/klighd-core/src/preferences-registry.ts @@ -3,7 +3,7 @@ * * http://rtsys.informatik.uni-kiel.de/kieler * - * Copyright 2021 by + * Copyright 2021-2024 by * + Kiel University * + Department of Computer Science * + Real-Time and Embedded Systems Group @@ -87,6 +87,31 @@ export class IncrementalDiagramGeneratorOption implements Preference { debug = true } +/** + * Switch between client-only and server-only layout. + */ +export class ClientLayoutOption implements Preference { + static readonly ID: string = 'diagram.clientLayout' + + static readonly NAME: string = 'Client Layout' + + readonly description: string | undefined = 'Switch between client-only and server-only layout.' + + readonly id: string = ClientLayoutOption.ID + + readonly name: string = ClientLayoutOption.NAME + + readonly type: TransformationOptionType = TransformationOptionType.CHECK + + readonly initialValue: boolean = false + + currentValue = false + + notifyServer = true + + debug = true +} + export interface PreferenceType { readonly ID: string readonly NAME: string @@ -116,6 +141,7 @@ export class PreferencesRegistry extends Registry { this.register(ShouldSelectDiagramOption) this.register(ShouldSelectTextOption) this.register(IncrementalDiagramGeneratorOption) + this.register(ClientLayoutOption) } @postConstruct() @@ -184,6 +210,7 @@ export class PreferencesRegistry extends Registry { 'diagram.shouldSelectDiagram': this.getValue(ShouldSelectDiagramOption), 'diagram.shouldSelectText': this.getValue(ShouldSelectTextOption), 'diagram.incrementalDiagramGenerator': this.getValue(IncrementalDiagramGeneratorOption), + 'diagram.clientLayout': this.getValue(ClientLayoutOption), } this.connection.sendNotification(NotificationType.SetPreferences, obj) }) diff --git a/packages/klighd-interactive/src/actions.ts b/packages/klighd-interactive/src/actions.ts index c482d346..f3c1c48f 100644 --- a/packages/klighd-interactive/src/actions.ts +++ b/packages/klighd-interactive/src/actions.ts @@ -3,7 +3,7 @@ * * http://rtsys.informatik.uni-kiel.de/kieler * - * Copyright 2020-2021 by + * Copyright 2020-2024 by * + Kiel University * + Department of Computer Science * + Real-Time and Embedded Systems Group @@ -17,7 +17,7 @@ // We follow Sprotty's way of redeclaring the interface and its create function, so disable this lint check for this file. /* eslint-disable no-redeclare */ -import { Action } from 'sprotty-protocol' +import { Action, JsonMap } from 'sprotty-protocol' import { DeleteConstraint } from './layered/constraint-types' /** @@ -25,14 +25,16 @@ import { DeleteConstraint } from './layered/constraint-types' */ export interface RefreshDiagramAction extends Action { kind: typeof RefreshDiagramAction.KIND + options?: JsonMap } export namespace RefreshDiagramAction { export const KIND = 'refreshDiagram' - export function create(): RefreshDiagramAction { + export function create(options?: JsonMap): RefreshDiagramAction { return { kind: KIND, + options, } } } diff --git a/schema/klighd/actions/refreshDiagram.json b/schema/klighd/actions/refreshDiagram.json index 56fc6379..bda306d8 100644 --- a/schema/klighd/actions/refreshDiagram.json +++ b/schema/klighd/actions/refreshDiagram.json @@ -3,12 +3,23 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "refreshDiagram", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "allOf": [{ "$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json" }], "required": ["kind"], "properties": { "kind": { "type": "string", "enum": ["refreshDiagram"] + }, + "options": { + "type": "object", + "properties": { + "needsClientLayout": { + "type": "boolean" + }, + "needsServerLayout": { + "type": "boolean" + } + } } } -} \ No newline at end of file +} diff --git a/schema/klighd/messages/preferencesSetPreferences.json b/schema/klighd/messages/preferencesSetPreferences.json index 227f8265..e5019394 100644 --- a/schema/klighd/messages/preferencesSetPreferences.json +++ b/schema/klighd/messages/preferencesSetPreferences.json @@ -21,6 +21,9 @@ }, "diagram.incrementalDiagramGenerator": { "type": "boolean" + }, + "diagram.clientLayout": { + "type": "boolean" } } } diff --git a/schema/sprotty/actions/requestModel.json b/schema/sprotty/actions/requestModel.json index 1aebcb5b..9f837ac4 100644 --- a/schema/sprotty/actions/requestModel.json +++ b/schema/sprotty/actions/requestModel.json @@ -1,9 +1,9 @@ { "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/actions/requestModel.json", "$schema": "http://json-schema.org/draft-07/schema#", - "title": "requestBounds", + "title": "requestModel", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], + "allOf": [{ "$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json" }], "required": ["kind", "options", "requestId"], "properties": { "kind": { @@ -32,4 +32,4 @@ "type": "string" } } -} \ No newline at end of file +} From 3f3fd9431d522bce38674dc6d06497f1481b8ddb Mon Sep 17 00:00:00 2001 From: Max Kasperowski Date: Tue, 12 Nov 2024 16:52:48 +0100 Subject: [PATCH 13/23] update version numbers --- applications/klighd-cli/package.json | 4 ++-- applications/klighd-vscode/package.json | 4 ++-- packages/klighd-core/package.json | 4 ++-- packages/klighd-interactive/package.json | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/applications/klighd-cli/package.json b/applications/klighd-cli/package.json index 9bc971db..96533d67 100644 --- a/applications/klighd-cli/package.json +++ b/applications/klighd-cli/package.json @@ -1,6 +1,6 @@ { "name": "@kieler/klighd-cli", - "version": "0.5.0", + "version": "0.6.0", "description": "Standalone web view for klighd-core diagrams", "author": "KIELER ", "license": "EPL-2.0", @@ -31,7 +31,7 @@ "socket": "node ./lib/main.js --ls_port=5007" }, "dependencies": { - "@kieler/klighd-core": "^0.5.0", + "@kieler/klighd-core": "^0.6.0", "buffer": "^6.0.3", "commander": "^8.1.0", "crypto-browserify": "^3.12.0", diff --git a/applications/klighd-vscode/package.json b/applications/klighd-vscode/package.json index 9f8c592e..aaad1d10 100644 --- a/applications/klighd-vscode/package.json +++ b/applications/klighd-vscode/package.json @@ -2,7 +2,7 @@ "name": "klighd-vscode", "displayName": "KLighD Diagrams", "description": "KLighD diagram support for Visual Studio Code", - "version": "0.5.0", + "version": "0.6.0", "publisher": "kieler", "author": "KIELER ", "icon": "icon.png", @@ -177,7 +177,7 @@ "webpack-cli": "^5.1.4" }, "dependencies": { - "@kieler/klighd-core": "^0.5.0", + "@kieler/klighd-core": "^0.6.0", "inversify": "^6.0.2", "nanoid": "^3.1.23", "reflect-metadata": "^0.2.1", diff --git a/packages/klighd-core/package.json b/packages/klighd-core/package.json index 8b420388..d61340e6 100644 --- a/packages/klighd-core/package.json +++ b/packages/klighd-core/package.json @@ -1,6 +1,6 @@ { "name": "@kieler/klighd-core", - "version": "0.5.0", + "version": "0.6.0", "description": "Core KLighD diagram visualization with Sprotty", "author": "KIELER ", "license": "EPL-2.0", @@ -24,7 +24,7 @@ "publish:next": "yarn publish --new-version \"$(semver $npm_package_version -i minor)-next.$(git rev-parse --short HEAD)\" --tag next --no-git-tag-version" }, "dependencies": { - "@kieler/klighd-interactive": "^0.5.0", + "@kieler/klighd-interactive": "^0.6.0", "@types/file-saver": "^2.0.7", "elkjs": "^0.8.2", "feather-icons": "^4.29.1", diff --git a/packages/klighd-interactive/package.json b/packages/klighd-interactive/package.json index bc60652b..4d39ecf4 100644 --- a/packages/klighd-interactive/package.json +++ b/packages/klighd-interactive/package.json @@ -1,6 +1,6 @@ { "name": "@kieler/klighd-interactive", - "version": "0.5.0", + "version": "0.6.0", "description": "A module for klighd-core to interactively apply constraints to the diagram", "author": "KIELER ", "license": "EPL-2.0", From 93ca838ac039b87509a99453fc5d033e187f644e Mon Sep 17 00:00:00 2001 From: Max Kasperowski Date: Wed, 13 Nov 2024 09:25:53 +0100 Subject: [PATCH 14/23] Update release mapping --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 290892ee..d5574098 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ related, web-based packages. The packages are seperated in two types: | ------------- | ------ | | 0.1.0–0.2.1 | 2.1.0 | | 0.3.0–0.4.2 | 2.2.0 | -| 0.5.0 | 3.0.2 | +| 0.5.0-0.6.0 | 3.0.2 | Moreover, the default branches of both repositories should be compatible but might experience regression. From 55173d104711d76e4ebc55f051ea1d22fd9e87dc Mon Sep 17 00:00:00 2001 From: Max Kasperowski Date: Thu, 14 Nov 2024 09:10:06 +0100 Subject: [PATCH 15/23] update and fix schemas --- schema/klighd/SKGraphSchema.json | 3 +++ schema/klighd/actions/checkImages.json | 2 +- schema/klighd/actions/checkedImages.json | 2 +- schema/klighd/actions/performAction.json | 2 +- schema/klighd/actions/refreshDiagram.json | 2 +- schema/klighd/actions/refreshLayout.json | 2 +- schema/klighd/actions/requestDiagramPiece.json | 2 +- schema/klighd/actions/setDiagramPiece.json | 4 ++-- schema/klighd/actions/setSyntheses.json | 2 +- schema/klighd/actions/setSynthesis.json | 2 +- schema/klighd/actions/storeImages.json | 4 ++-- schema/klighd/actions/updateOptions.json | 4 ++-- schema/klighd/messages/diagramOptionsPerformAction.json | 2 +- schema/klighd/messages/diagramOptionsSetLayoutOptions.json | 2 +- .../klighd/messages/diagramOptionsSetSynthesisOptions.json | 4 ++-- schema/klighd/messages/preferencesSetPreferences.json | 2 +- schema/lsp/generalSendMessage.json | 2 +- schema/lsp/initialize.json | 2 +- schema/lsp/range.json | 6 +++--- schema/lsp/requestMessage.json | 4 ++-- schema/lsp/responseMessage.json | 4 ++-- schema/lsp/textDocumentDocumentHighlight.json | 4 ++-- schema/sprotty/actions/action.json | 2 +- schema/sprotty/actions/allSelected.json | 2 +- schema/sprotty/actions/elementSelected.json | 2 +- schema/sprotty/actions/fit.json | 2 +- schema/sprotty/actions/requestBounds.json | 4 ++-- schema/sprotty/actions/requestModel.json | 2 +- schema/sprotty/actions/setModel.json | 4 ++-- schema/sprotty/actions/updateModel.json | 4 ++-- schema/sprotty/diagramAccept.json | 4 ++-- schema/sprotty/diagramOpenInTextEditor.json | 4 ++-- 32 files changed, 48 insertions(+), 45 deletions(-) diff --git a/schema/klighd/SKGraphSchema.json b/schema/klighd/SKGraphSchema.json index fb86effc..9aad4a6b 100644 --- a/schema/klighd/SKGraphSchema.json +++ b/schema/klighd/SKGraphSchema.json @@ -193,6 +193,9 @@ "type": { "type": "string", "default": "KRenderingImpl" + }, + "id": { + "type": "string" } } }, diff --git a/schema/klighd/actions/checkImages.json b/schema/klighd/actions/checkImages.json index c5c7006a..95b9c940 100644 --- a/schema/klighd/actions/checkImages.json +++ b/schema/klighd/actions/checkImages.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "checkImages", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "allOf": [{"$ref": "../../sprotty/actions/action.json"}], "required": ["kind", "images"], "properties": { "kind": { diff --git a/schema/klighd/actions/checkedImages.json b/schema/klighd/actions/checkedImages.json index 6e5445cc..531981cf 100644 --- a/schema/klighd/actions/checkedImages.json +++ b/schema/klighd/actions/checkedImages.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "checkedImages", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "allOf": [{"$ref": "../../sprotty/actions/action.json"}], "required": ["kind", "notCached", "responseId"], "properties": { "kind": { diff --git a/schema/klighd/actions/performAction.json b/schema/klighd/actions/performAction.json index 0dfe923d..12a98dce 100644 --- a/schema/klighd/actions/performAction.json +++ b/schema/klighd/actions/performAction.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "performAction", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], + "allOf": [{"$ref": "../../sprotty/actions/action.json"}], "required": ["kind", "actionId", "kGraphElementId", "kRenderingId", "revision"], "properties": { "kind": { diff --git a/schema/klighd/actions/refreshDiagram.json b/schema/klighd/actions/refreshDiagram.json index bda306d8..d6888e9c 100644 --- a/schema/klighd/actions/refreshDiagram.json +++ b/schema/klighd/actions/refreshDiagram.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "refreshDiagram", "type": "object", - "allOf": [{ "$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json" }], + "allOf": [{ "$ref": "../../sprotty/actions/action.json" }], "required": ["kind"], "properties": { "kind": { diff --git a/schema/klighd/actions/refreshLayout.json b/schema/klighd/actions/refreshLayout.json index 0f322b89..b6b3720d 100644 --- a/schema/klighd/actions/refreshLayout.json +++ b/schema/klighd/actions/refreshLayout.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "refreshLayout", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "allOf": [{"$ref": "../../sprotty/actions/action.json"}], "required": ["kind"], "properties": { "kind": { diff --git a/schema/klighd/actions/requestDiagramPiece.json b/schema/klighd/actions/requestDiagramPiece.json index 9d92c8eb..234e16ce 100644 --- a/schema/klighd/actions/requestDiagramPiece.json +++ b/schema/klighd/actions/requestDiagramPiece.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "requestDiagramPiece", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "allOf": [{"$ref": "../../sprotty/actions/action.json"}], "required": ["kind", "modelElementId"], "properties": { "kind": { diff --git a/schema/klighd/actions/setDiagramPiece.json b/schema/klighd/actions/setDiagramPiece.json index b538bb30..acc2b1a5 100644 --- a/schema/klighd/actions/setDiagramPiece.json +++ b/schema/klighd/actions/setDiagramPiece.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "setDiagramPiece", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "allOf": [{"$ref": "../../sprotty/actions/action.json"}], "required": ["kind", "diagramPiece"], "properties": { "kind": { @@ -11,7 +11,7 @@ "enum": ["setDiagramPiece"] }, "diagramPiece": { - "$ref": "/kieler/klighd-vscode/tree/main/schema/klighd/SKGraphSchema.json#/definitions/SKNode" + "$ref": "../SKGraphSchema.json#/definitions/SKNode" } } } \ No newline at end of file diff --git a/schema/klighd/actions/setSyntheses.json b/schema/klighd/actions/setSyntheses.json index 37aae4a3..9a5efd7c 100644 --- a/schema/klighd/actions/setSyntheses.json +++ b/schema/klighd/actions/setSyntheses.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "setSyntheses", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "allOf": [{"$ref": "../../sprotty/actions/action.json"}], "required": ["kind", "syntheses"], "properties": { "kind": { diff --git a/schema/klighd/actions/setSynthesis.json b/schema/klighd/actions/setSynthesis.json index 1cdc4d50..ff9e66fd 100644 --- a/schema/klighd/actions/setSynthesis.json +++ b/schema/klighd/actions/setSynthesis.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "setSynthesis", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "allOf": [{"$ref": "../../sprotty/actions/action.json"}], "required": ["kind", "id"], "properties": { "kind": { diff --git a/schema/klighd/actions/storeImages.json b/schema/klighd/actions/storeImages.json index c58f4c66..d030585d 100644 --- a/schema/klighd/actions/storeImages.json +++ b/schema/klighd/actions/storeImages.json @@ -4,7 +4,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "storeImages", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "allOf": [{"$ref": "../../sprotty/actions/action.json"}], "required": ["kind", "images"], "properties": { "kind": { @@ -16,7 +16,7 @@ "required": ["k", "v"], "properties": { "k": { - "$ref": "/kieler/klighd-vscode/tree/main/schema/klighd/actions/checkedImages.json#/definitions/notCachedImage" + "$ref": "checkedImages.json#/definitions/notCachedImage" }, "v": { "type": "string" diff --git a/schema/klighd/actions/updateOptions.json b/schema/klighd/actions/updateOptions.json index 8084bf9a..adad5747 100644 --- a/schema/klighd/actions/updateOptions.json +++ b/schema/klighd/actions/updateOptions.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "updateOptions", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/action.json"}], + "allOf": [{"$ref": "../../sprotty/actions/action.json"}], "required": ["kind", "valuedSynthesisOptions", "layoutOptions", "actions", "modelUri"], "properties": { "kind": { @@ -13,7 +13,7 @@ "valuedSynthesisOptions": { "type": "array", "items": { - "$ref": "/kieler/klighd-vscode/tree/main/schema/klighd/valuedSynthesisOption.json" + "$ref": "../ValuedSynthesisOption.json" } }, "layoutOptions": { diff --git a/schema/klighd/messages/diagramOptionsPerformAction.json b/schema/klighd/messages/diagramOptionsPerformAction.json index 48628e22..bfe120f2 100644 --- a/schema/klighd/messages/diagramOptionsPerformAction.json +++ b/schema/klighd/messages/diagramOptionsPerformAction.json @@ -2,7 +2,7 @@ "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/messages/diagramOptionsPerformAction.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "keith/diagramOptions/performAction", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/requestMessage.json"}], + "allOf": [{"$ref": "../../lsp/requestMessage.json"}], "required": ["method", "params"], "properties": { "method": { diff --git a/schema/klighd/messages/diagramOptionsSetLayoutOptions.json b/schema/klighd/messages/diagramOptionsSetLayoutOptions.json index cacc7e8e..2b24ebb6 100644 --- a/schema/klighd/messages/diagramOptionsSetLayoutOptions.json +++ b/schema/klighd/messages/diagramOptionsSetLayoutOptions.json @@ -2,7 +2,7 @@ "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/messages/diagramOptionsSetLayoutOptions.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "keith/diagramOptions/setLayoutOptions", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/requestMessage.json"}], + "allOf": [{"$ref": "../../lsp/requestMessage.json"}], "required": ["method", "params"], "properties": { "method": { diff --git a/schema/klighd/messages/diagramOptionsSetSynthesisOptions.json b/schema/klighd/messages/diagramOptionsSetSynthesisOptions.json index 6d60dae1..46145d07 100644 --- a/schema/klighd/messages/diagramOptionsSetSynthesisOptions.json +++ b/schema/klighd/messages/diagramOptionsSetSynthesisOptions.json @@ -2,7 +2,7 @@ "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/messages/diagramOptionsSetSynthesisOptions.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "keith/diagramOptions/setSynthesisOptions", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/requestMessage.json"}], + "allOf": [{"$ref": "../../lsp/requestMessage.json"}], "required": ["method", "params"], "properties": { "method": { @@ -16,7 +16,7 @@ "synthesisOptions": { "type": "array", "items": { - "$ref": "/kieler/klighd-vscode/tree/main/schema/klighd/valuedSynthesisOption.json" + "$ref": "../ValuedSynthesisOption.json" } }, "uri": { diff --git a/schema/klighd/messages/preferencesSetPreferences.json b/schema/klighd/messages/preferencesSetPreferences.json index e5019394..d470f4bb 100644 --- a/schema/klighd/messages/preferencesSetPreferences.json +++ b/schema/klighd/messages/preferencesSetPreferences.json @@ -2,7 +2,7 @@ "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/klighd/messages/preferencesSetPreferences.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "keith/preferences/setPreferences", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/requestMessage.json"}], + "allOf": [{"$ref": "../../lsp/requestMessage.json"}], "required": ["method", "params"], "properties": { "method": { diff --git a/schema/lsp/generalSendMessage.json b/schema/lsp/generalSendMessage.json index 6da08838..469a5b0f 100644 --- a/schema/lsp/generalSendMessage.json +++ b/schema/lsp/generalSendMessage.json @@ -2,7 +2,7 @@ "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/lsp/generalSendMessage.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "general/sendMessage", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/lsp/requestMessage.json"}], + "allOf": [{"$ref": "requestMessage.json"}], "required": ["method", "params"], "properties": { "method": { diff --git a/schema/lsp/initialize.json b/schema/lsp/initialize.json index ae7b5766..4e61f60e 100644 --- a/schema/lsp/initialize.json +++ b/schema/lsp/initialize.json @@ -2,7 +2,7 @@ "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/lsp/initialize.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "initialize", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/lsp/requestMessage.json"}], + "allOf": [{"$ref": "requestMessage.json"}], "required": ["method", "params"], "properties": { "method": { diff --git a/schema/lsp/range.json b/schema/lsp/range.json index 47f7a90a..c6a81344 100644 --- a/schema/lsp/range.json +++ b/schema/lsp/range.json @@ -6,14 +6,14 @@ "required": ["start", "end"], "properties": { "start": { - "$ref": "#/definitions/editorPosition.json" + "$ref": "#/definitions/editorPosition" }, "end": { - "$ref": "#/definitions/editorPosition.json" + "$ref": "#/definitions/editorPosition" } }, "definitions": { - "editorPosition.json": { + "editorPosition": { "type": "object", "required": ["line", "character"], "properties": { diff --git a/schema/lsp/requestMessage.json b/schema/lsp/requestMessage.json index 03924db3..b6623274 100644 --- a/schema/lsp/requestMessage.json +++ b/schema/lsp/requestMessage.json @@ -1,8 +1,8 @@ { "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/lsp/requestmessage.json", "$schema": "http://json-schema.org/draft-07/schema#", - "title": "message", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/lsp/message.json"}], + "title": "requestMessage", + "allOf": [{"$ref": "message.json"}], "required": ["method"], "properties": { "id": { diff --git a/schema/lsp/responseMessage.json b/schema/lsp/responseMessage.json index 48db567e..abf569df 100644 --- a/schema/lsp/responseMessage.json +++ b/schema/lsp/responseMessage.json @@ -1,8 +1,8 @@ { "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/lsp/requestmessage.json", "$schema": "http://json-schema.org/draft-07/schema#", - "title": "message", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/lsp/message.json"}], + "title": "responseMessage", + "allOf": [{"$ref": "message.json"}], "required": ["id"], "oneOf": [{"required": ["result"]}, {"required": ["error"]}], "properties": { diff --git a/schema/lsp/textDocumentDocumentHighlight.json b/schema/lsp/textDocumentDocumentHighlight.json index 998e3fbe..1f447f04 100644 --- a/schema/lsp/textDocumentDocumentHighlight.json +++ b/schema/lsp/textDocumentDocumentHighlight.json @@ -2,7 +2,7 @@ "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/lsp/textDocumentDocumentHighlight.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "textDocument/documentHighlight", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/lsp/requestMessage.json"}], + "allOf": [{"$ref": "requestMessage.json"}], "required": ["method", "params"], "properties": { "method": { @@ -21,7 +21,7 @@ } }, "position": { - "$ref": "/kieler/klighd-vscode/tree/main/schema/lsp/position.json" + "$ref": "range.json#/editorPosition" } } } diff --git a/schema/sprotty/actions/action.json b/schema/sprotty/actions/action.json index 2cb2fa92..50b6716f 100644 --- a/schema/sprotty/actions/action.json +++ b/schema/sprotty/actions/action.json @@ -1,5 +1,5 @@ { - "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json", + "$id": "https://github.com../../sprotty/actions/action.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "action", "type": "object", diff --git a/schema/sprotty/actions/allSelected.json b/schema/sprotty/actions/allSelected.json index 1214c45a..3497e60a 100644 --- a/schema/sprotty/actions/allSelected.json +++ b/schema/sprotty/actions/allSelected.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "allSelected", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], + "allOf": [{"$ref": "action.json"}], "required": ["kind", "select"], "properties": { "kind": { diff --git a/schema/sprotty/actions/elementSelected.json b/schema/sprotty/actions/elementSelected.json index f19c3619..90a4dd05 100644 --- a/schema/sprotty/actions/elementSelected.json +++ b/schema/sprotty/actions/elementSelected.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "elementSelected", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], + "allOf": [{"$ref": "action.json"}], "required": ["kind", "selectedElementsIDs", "deselectedElementsIDs", "preventOpenSelection"], "properties": { "kind": { diff --git a/schema/sprotty/actions/fit.json b/schema/sprotty/actions/fit.json index 9a82a5cf..6aa4e25f 100644 --- a/schema/sprotty/actions/fit.json +++ b/schema/sprotty/actions/fit.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "fit", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], + "allOf": [{"$ref": "action.json"}], "required": ["kind", "elementIds", "maxZoom", "animate"], "properties": { "kind": { diff --git a/schema/sprotty/actions/requestBounds.json b/schema/sprotty/actions/requestBounds.json index 9ad3dd50..21629697 100644 --- a/schema/sprotty/actions/requestBounds.json +++ b/schema/sprotty/actions/requestBounds.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "requestBounds", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], + "allOf": [{"$ref": "action.json"}], "required": ["kind", "newRoot"], "properties": { "kind": { @@ -11,7 +11,7 @@ "enum": ["requestBounds"] }, "newRoot": { - "$ref": "/kieler/klighd-vscode/tree/main/schema/klighd/SKGraphSchema#/definitions/SKGraph" + "$ref": "../../klighd/SKGraphSchema.json#/definitions/SKGraph" } } } \ No newline at end of file diff --git a/schema/sprotty/actions/requestModel.json b/schema/sprotty/actions/requestModel.json index 9f837ac4..2c6f3d2d 100644 --- a/schema/sprotty/actions/requestModel.json +++ b/schema/sprotty/actions/requestModel.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "requestModel", "type": "object", - "allOf": [{ "$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json" }], + "allOf": [{ "$ref": "action.json" }], "required": ["kind", "options", "requestId"], "properties": { "kind": { diff --git a/schema/sprotty/actions/setModel.json b/schema/sprotty/actions/setModel.json index ff8d309d..459b847f 100644 --- a/schema/sprotty/actions/setModel.json +++ b/schema/sprotty/actions/setModel.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "setModel", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], + "allOf": [{"$ref": "action.json"}], "required": ["kind", "newRoot"], "properties": { "kind": { @@ -11,7 +11,7 @@ "enum": ["setModel"] }, "newRoot": { - "$ref": "/kieler/klighd-vscode/tree/main/schema/klighd/SKGraphSchema#/definitions/SKGraph" + "$ref": "../../klighd/SKGraphSchema.json#/definitions/SKGraph" } } } \ No newline at end of file diff --git a/schema/sprotty/actions/updateModel.json b/schema/sprotty/actions/updateModel.json index a6c1a1b8..f5960e7c 100644 --- a/schema/sprotty/actions/updateModel.json +++ b/schema/sprotty/actions/updateModel.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "updateModel", "type": "object", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json"}], + "allOf": [{"$ref": "action.json"}], "required": ["kind", "newRoot"], "properties": { "kind": { @@ -11,7 +11,7 @@ "enum": ["updateModel"] }, "newRoot": { - "$ref": "/kieler/klighd-vscode/tree/main/schema/klighd/SKGraphSchema#/definitions/SKGraph" + "$ref": "../../klighd/SKGraphSchema.json#/definitions/SKGraph" } } } \ No newline at end of file diff --git a/schema/sprotty/diagramAccept.json b/schema/sprotty/diagramAccept.json index 531bb740..6c924ac3 100644 --- a/schema/sprotty/diagramAccept.json +++ b/schema/sprotty/diagramAccept.json @@ -2,7 +2,7 @@ "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/messages/diagramAccept.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "diagram/accept", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/requestMessage.json"}], + "allOf": [{"$ref": "../lsp/requestMessage.json"}], "required": ["method", "params"], "properties": { "method": { @@ -18,7 +18,7 @@ "enum": ["sprotty"] }, "action": { - "$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/actions/action.json" + "$ref": "actions/action.json" } } } diff --git a/schema/sprotty/diagramOpenInTextEditor.json b/schema/sprotty/diagramOpenInTextEditor.json index 0be1cbd9..9b925ba3 100644 --- a/schema/sprotty/diagramOpenInTextEditor.json +++ b/schema/sprotty/diagramOpenInTextEditor.json @@ -2,7 +2,7 @@ "$id": "https://github.com/kieler/klighd-vscode/tree/main/schema/sprotty/messages/diagramOpenInTextEditor.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "diagram/openInTextEditor", - "allOf": [{"$ref": "/kieler/klighd-vscode/tree/main/schema/sprotty/requestMessage.json"}], + "allOf": [{"$ref": "../lsp/requestMessage.json"}], "required": ["method", "params"], "properties": { "method": { @@ -31,7 +31,7 @@ "type": "string" }, "range": { - "$ref": "/kieler/klighd-vscode/tree/main/schema/lsp/range.json" + "$ref": "../lsp/range.json" } } } From 701c40db0fea960448287cc40aa4a63ee6cc10ae Mon Sep 17 00:00:00 2001 From: Max Kasperowski Date: Thu, 14 Nov 2024 12:23:49 +0100 Subject: [PATCH 16/23] remove id field from KRendering schema --- schema/klighd/SKGraphSchema.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/schema/klighd/SKGraphSchema.json b/schema/klighd/SKGraphSchema.json index 9aad4a6b..fb86effc 100644 --- a/schema/klighd/SKGraphSchema.json +++ b/schema/klighd/SKGraphSchema.json @@ -193,9 +193,6 @@ "type": { "type": "string", "default": "KRenderingImpl" - }, - "id": { - "type": "string" } } }, From 2a9caa0bb1a4de354afae669d4fa67f7193f752e Mon Sep 17 00:00:00 2001 From: Max Kasperowski Date: Fri, 15 Nov 2024 10:44:51 +0100 Subject: [PATCH 17/23] Create build-types.yml --- .github/workflows/build-types.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/build-types.yml diff --git a/.github/workflows/build-types.yml b/.github/workflows/build-types.yml new file mode 100644 index 00000000..d3fc89fc --- /dev/null +++ b/.github/workflows/build-types.yml @@ -0,0 +1,19 @@ +name: Test Type Generation from Schemas + +on: + pull_request: + +jobs: + build-pydantic: + runs-on: ubuntu-latest + steps: + - name: Install datamodel-code-generator + id: install_code_generator + run: | + python -m venv ls-env + source ls-env/bin/activate + pip install datamodel-code-generator + - name: Generate Pydantic types + id: generate_pydantic_types + run: | + datamodel-codegen --input schema/ --input-file-type jsonschema --output GEN/ --use-default From 09a94fd1105ac0e817fd658df4cdfb43a40ba137 Mon Sep 17 00:00:00 2001 From: Max Kasperowski Date: Fri, 15 Nov 2024 10:47:23 +0100 Subject: [PATCH 18/23] Update build-types.yml --- .github/workflows/build-types.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-types.yml b/.github/workflows/build-types.yml index d3fc89fc..0e47852b 100644 --- a/.github/workflows/build-types.yml +++ b/.github/workflows/build-types.yml @@ -16,4 +16,5 @@ jobs: - name: Generate Pydantic types id: generate_pydantic_types run: | + source ls-env/bin/activate datamodel-codegen --input schema/ --input-file-type jsonschema --output GEN/ --use-default From 9dc4b74fd268996d4b8e75237052a5cc41d3f107 Mon Sep 17 00:00:00 2001 From: Max Kasperowski Date: Fri, 15 Nov 2024 10:56:06 +0100 Subject: [PATCH 19/23] Update build-types.yml --- .github/workflows/build-types.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build-types.yml b/.github/workflows/build-types.yml index 0e47852b..46935e8f 100644 --- a/.github/workflows/build-types.yml +++ b/.github/workflows/build-types.yml @@ -7,6 +7,12 @@ jobs: build-pydantic: runs-on: ubuntu-latest steps: + - name: Checkout repository + id: checkout_repository + uses: actions/checkout@v4 + with: + sparse-checkout: schema + fetch-depth: 1 - name: Install datamodel-code-generator id: install_code_generator run: | From 470f3d88cfb0ed22bfe46723c119ac24c860b589 Mon Sep 17 00:00:00 2001 From: Max Kasperowski Date: Fri, 15 Nov 2024 11:10:40 +0100 Subject: [PATCH 20/23] Update build-types.yml --- .github/workflows/build-types.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-types.yml b/.github/workflows/build-types.yml index 46935e8f..023a5945 100644 --- a/.github/workflows/build-types.yml +++ b/.github/workflows/build-types.yml @@ -2,6 +2,8 @@ name: Test Type Generation from Schemas on: pull_request: + paths: + - schema/ jobs: build-pydantic: From 0fda145cc3f39943b2a0c40f88d704947d2b5f84 Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Wed, 27 Nov 2024 15:26:53 +0100 Subject: [PATCH 21/23] fixed flex layout in chrome for option checkboxes --- .../src/options/components/option-inputs.tsx | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/klighd-core/src/options/components/option-inputs.tsx b/packages/klighd-core/src/options/components/option-inputs.tsx index 8491e6fa..052cb3d9 100644 --- a/packages/klighd-core/src/options/components/option-inputs.tsx +++ b/packages/klighd-core/src/options/components/option-inputs.tsx @@ -35,17 +35,19 @@ type CheckOptionProps = BaseProps /** Render a labeled checkbox input. */ export function CheckOption(props: CheckOptionProps): VNode { return ( - +
+ +
) } From a036b1e2208c3d3a667a707e0df06c6e21db72ed Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Wed, 18 Dec 2024 15:38:17 +0100 Subject: [PATCH 22/23] prettier and API changes for dark theme --- .../klighd-cli/src/services/connection.ts | 14 +++--- applications/klighd-vscode/src/extension.ts | 15 ++++++- packages/klighd-core/src/actions/actions.ts | 8 ++-- packages/klighd-core/src/diagram-server.ts | 43 +++++++++++-------- 4 files changed, 51 insertions(+), 29 deletions(-) diff --git a/applications/klighd-cli/src/services/connection.ts b/applications/klighd-cli/src/services/connection.ts index 26201b26..23dd20ca 100644 --- a/applications/klighd-cli/src/services/connection.ts +++ b/applications/klighd-cli/src/services/connection.ts @@ -19,7 +19,7 @@ import * as rpc from 'vscode-ws-jsonrpc' import * as lsp from 'vscode-languageserver-protocol' import { Connection, NotificationType, ActionMessage } from '@kieler/klighd-core' import { showPopup } from '../popup' -/* global WebSocket */ +/* global WebSocket, window */ type GeneralMessageParams = [string, 'info' | 'warn' | 'error'] @@ -159,14 +159,14 @@ export class LSPConnection implements Connection { if (!this.connection) return // notify the server about the preferred colors, depending on if the OS prefers light (default) or dark theme. - let foreground = "#000000" - let background = "#ffffff" - let highlight = "#000000" + let foreground = '#000000' + let background = '#ffffff' + let highlight = '#000000' if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { // dark mode - foreground = "#cccccc" - background = "#1f1f1f" - highlight = "#cccccc" + foreground = '#cccccc' + background = '#1f1f1f' + highlight = '#cccccc' } const { method } = lsp.InitializeRequest.type diff --git a/applications/klighd-vscode/src/extension.ts b/applications/klighd-vscode/src/extension.ts index 6b3b3157..d33105ec 100644 --- a/applications/klighd-vscode/src/extension.ts +++ b/applications/klighd-vscode/src/extension.ts @@ -18,7 +18,7 @@ // See https://stackoverflow.com/questions/37534890/inversify-js-reflect-hasownmetadata-is-not-a-function import 'reflect-metadata' // The other imports. -import { DebugOptions, SetRenderOptionAction } from '@kieler/klighd-core' +import { ChangeColorThemeAction, DebugOptions, SetRenderOptionAction } from '@kieler/klighd-core' import { diagramType } from '@kieler/klighd-core/lib/base/external-helpers' import { Action, ActionMessage, isAction } from 'sprotty-protocol' import { registerLspEditCommands } from 'sprotty-vscode' @@ -78,6 +78,7 @@ export function activate(context: vscode.ExtensionContext): void { registerCommands(webviewPanelManager, context) registerLspEditCommands(webviewPanelManager, context, { extensionPrefix: 'klighd-vscode' }) registerTextEditorSync(webviewPanelManager, context) + registerChangeColorTheme(webviewPanelManager) // Handle notifications that are KLighD specific extensions of the LSP for this LSClient. LspHandler.init(client) @@ -193,3 +194,15 @@ function isLanguageClient(client: unknown): client is LanguageClient { function isFileEndingsArray(array: unknown): array is string[] { return Array.isArray(array) && array.every((val) => typeof val === 'string') } +/** + * Hook into VS Code's theme change and notify the webview to check the current colors and send them to the server. + */ +function registerChangeColorTheme(manager: KLighDWebviewPanelManager) { + vscode.window.onDidChangeActiveColorTheme(() => { + for (const endpoint of manager.endpoints) { + endpoint.sendAction({ + kind: ChangeColorThemeAction.KIND, + }) + } + }) +} diff --git a/packages/klighd-core/src/actions/actions.ts b/packages/klighd-core/src/actions/actions.ts index 9b1cf72f..29ae2e5a 100644 --- a/packages/klighd-core/src/actions/actions.ts +++ b/packages/klighd-core/src/actions/actions.ts @@ -101,7 +101,7 @@ export namespace CheckedImagesAction { } /** - * Sent internally to notify KLighD that the color theme has changed. Will trigger a subsequent + * Sent internally to notify KLighD that the color theme has changed. Will trigger a subsequent * ClientColorPreferencesAction to be triggered and sent. */ export interface ChangeColorThemeAction extends Action { @@ -142,9 +142,9 @@ export namespace ClientColorPreferencesAction { * The color preferences data class, indicating diagram colors to be used by syntheses. */ export interface ColorPreferences { - foreground: string, - background: string, - highlight: string, + foreground: string + background: string + highlight: string } /** diff --git a/packages/klighd-core/src/diagram-server.ts b/packages/klighd-core/src/diagram-server.ts index d43f1fdb..0a2b72a5 100644 --- a/packages/klighd-core/src/diagram-server.ts +++ b/packages/klighd-core/src/diagram-server.ts @@ -90,6 +90,7 @@ import { ClientLayoutOption, IncrementalDiagramGeneratorOption, PreferencesRegis import { Connection, ServiceTypes, SessionStorage } from './services' import { SetSynthesisAction } from './syntheses/actions' import { UpdateDepthMapModelAction } from './update/update-depthmap-model' +/* global document, getComputedStyle */ /** * This class extends {@link DiagramServerProxy} to handle different `klighd-core` specific @@ -169,13 +170,13 @@ export class KlighdDiagramServer extends DiagramServerProxy { } handleLocally(action: Action): boolean { - // In contract to the name, this should return true, if the actions should be + // In contrast to the name, this should return true, if the actions should be // sent to the server. Don't know what the Sprotty folks where thinking when they named it... switch (action.kind) { case ClientColorPreferencesAction.KIND: - return true; + return true case ChangeColorThemeAction.KIND: - return false; + return false case PerformActionAction.KIND: return true case RefreshDiagramAction.KIND: @@ -213,8 +214,8 @@ export class KlighdDiagramServer extends DiagramServerProxy { registry.register(BringToFrontAction.KIND, this) registry.register(CheckImagesAction.KIND, this) registry.register(CheckedImagesAction.KIND, this) - registry.register(ClientColorPreferencesAction.KIND, this); - registry.register(ChangeColorThemeAction.KIND, this); + registry.register(ClientColorPreferencesAction.KIND, this) + registry.register(ChangeColorThemeAction.KIND, this) registry.register(DeleteLayerConstraintAction.KIND, this) registry.register(DeletePositionConstraintAction.KIND, this) registry.register(DeleteStaticConstraintAction.KIND, this) @@ -245,14 +246,20 @@ export class KlighdDiagramServer extends DiagramServerProxy { handle(action: Action): void | ICommand | Action { if (action.kind === RequestModelAction.KIND && getComputedStyle !== undefined) { - // On any request model action, also send the current colors with the request, so the initial + // On any request model action, also send the current colors with the request, so the initial // syntheses can use the theming of VS Code. Values will be undefined outside of VS Code and should // be ignored. - (action as RequestModelAction).options = { - ...((action as RequestModelAction).options), - clientColorPreferenceForeground: getComputedStyle(document.documentElement).getPropertyValue('--vscode-editor-foreground'), - clientColorPreferenceBackground: getComputedStyle(document.documentElement).getPropertyValue('--vscode-editor-background'), - clientColorPreferenceHighlight: getComputedStyle(document.documentElement).getPropertyValue('--vscode-focusBorder') + ;(action as RequestModelAction).options = { + ...(action as RequestModelAction).options, + clientColorPreferenceForeground: getComputedStyle(document.documentElement).getPropertyValue( + '--vscode-editor-foreground' + ), + clientColorPreferenceBackground: getComputedStyle(document.documentElement).getPropertyValue( + '--vscode-editor-background' + ), + clientColorPreferenceHighlight: getComputedStyle(document.documentElement).getPropertyValue( + '--vscode-focusBorder' + ), } super.handle(action) } @@ -265,7 +272,7 @@ export class KlighdDiagramServer extends DiagramServerProxy { if (action.kind === CheckImagesAction.KIND) { this.handleCheckImages(action as CheckImagesAction) } else if (action.kind === ChangeColorThemeAction.KIND) { - this.handleChangeColorTheme(); + this.handleChangeColorTheme() } else if (action.kind === StoreImagesAction.KIND) { this.handleStoreImages(action as StoreImagesAction) } else if (action.kind === RequestPopupModelAction.KIND) { @@ -297,11 +304,13 @@ export class KlighdDiagramServer extends DiagramServerProxy { handleChangeColorTheme(): void { if (getComputedStyle === undefined) return - this.actionDispatcher.dispatch(ClientColorPreferencesAction.create({ - foreground: getComputedStyle(document.documentElement).getPropertyValue('--vscode-editor-foreground'), - background: getComputedStyle(document.documentElement).getPropertyValue('--vscode-editor-background'), - highlight: getComputedStyle(document.documentElement).getPropertyValue('--vscode-focusBorder'), - })) + this.actionDispatcher.dispatch( + ClientColorPreferencesAction.create({ + foreground: getComputedStyle(document.documentElement).getPropertyValue('--vscode-editor-foreground'), + background: getComputedStyle(document.documentElement).getPropertyValue('--vscode-editor-background'), + highlight: getComputedStyle(document.documentElement).getPropertyValue('--vscode-focusBorder'), + }) + ) } handleStoreImages(action: StoreImagesAction): void { From ecac948f340b3262fa26ca62cbce9ac9c959eb55 Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Fri, 20 Dec 2024 14:06:32 +0100 Subject: [PATCH 23/23] CLI supports dark theme. Initialize sends current theme type of CLI/ theme type and colors (hardcoded) of VS Code, concrete colors also on theme change (VS Code). Removes ForceLightBackground option --- .../klighd-cli/src/services/connection.ts | 18 ++--- applications/klighd-cli/src/styles/main.css | 7 +- applications/klighd-vscode/src/extension.ts | 69 +++++++++++++++++-- packages/klighd-core/src/actions/actions.ts | 33 +++++++-- packages/klighd-core/src/diagram-server.ts | 25 ++----- packages/klighd-core/src/model-viewer.ts | 20 +----- .../src/options/render-options-registry.ts | 26 ------- packages/klighd-core/src/views.tsx | 15 +++- packages/klighd-core/styles/theme.css | 16 ++++- 9 files changed, 138 insertions(+), 91 deletions(-) diff --git a/applications/klighd-cli/src/services/connection.ts b/applications/klighd-cli/src/services/connection.ts index 23dd20ca..9595cf24 100644 --- a/applications/klighd-cli/src/services/connection.ts +++ b/applications/klighd-cli/src/services/connection.ts @@ -3,7 +3,7 @@ * * http://rtsys.informatik.uni-kiel.de/kieler * - * Copyright 2021 by + * Copyright 2021-2024 by * + Kiel University * + Department of Computer Science * + Real-Time and Embedded Systems Group @@ -17,7 +17,7 @@ import * as rpc from 'vscode-ws-jsonrpc' import * as lsp from 'vscode-languageserver-protocol' -import { Connection, NotificationType, ActionMessage } from '@kieler/klighd-core' +import { Connection, NotificationType, ActionMessage, ColorThemeKind } from '@kieler/klighd-core' import { showPopup } from '../popup' /* global WebSocket, window */ @@ -159,18 +159,14 @@ export class LSPConnection implements Connection { if (!this.connection) return // notify the server about the preferred colors, depending on if the OS prefers light (default) or dark theme. - let foreground = '#000000' - let background = '#ffffff' - let highlight = '#000000' + let themeKind = ColorThemeKind.LIGHT if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { // dark mode - foreground = '#cccccc' - background = '#1f1f1f' - highlight = '#cccccc' + themeKind = ColorThemeKind.DARK } const { method } = lsp.InitializeRequest.type - // The standalone view does not really has any LSP capabilities + // The standalone view does not really have any LSP capabilities const initParams: lsp.InitializeParams = { processId: null, workspaceFolders: null, @@ -180,9 +176,7 @@ export class LSPConnection implements Connection { initializationOptions: { clientDiagramOptions: persistedData, clientColorPreferences: { - foreground, - background, - highlight, + kind: themeKind, }, }, } diff --git a/applications/klighd-cli/src/styles/main.css b/applications/klighd-cli/src/styles/main.css index 6715a36f..4e660ad6 100644 --- a/applications/klighd-cli/src/styles/main.css +++ b/applications/klighd-cli/src/styles/main.css @@ -3,7 +3,7 @@ * * http://rtsys.informatik.uni-kiel.de/kieler * - * Copyright 2021 by + * Copyright 2021-2024 by * + Kiel University * + Department of Computer Science * + Real-Time and Embedded Systems Group @@ -22,6 +22,11 @@ --color-accent-blue: #1992d4; --color-background: #f7f7f7; } +@media (prefers-color-scheme: dark) { + :root { + --color-background: #1e1e1e; + } +} body { margin: 0; diff --git a/applications/klighd-vscode/src/extension.ts b/applications/klighd-vscode/src/extension.ts index d33105ec..5cffcb55 100644 --- a/applications/klighd-vscode/src/extension.ts +++ b/applications/klighd-vscode/src/extension.ts @@ -3,7 +3,7 @@ * * http://rtsys.informatik.uni-kiel.de/kieler * - * Copyright 2021-2023 by + * Copyright 2021-2024 by * + Kiel University * + Department of Computer Science * + Real-Time and Embedded Systems Group @@ -18,7 +18,7 @@ // See https://stackoverflow.com/questions/37534890/inversify-js-reflect-hasownmetadata-is-not-a-function import 'reflect-metadata' // The other imports. -import { ChangeColorThemeAction, DebugOptions, SetRenderOptionAction } from '@kieler/klighd-core' +import { ChangeColorThemeAction, ColorThemeKind, DebugOptions, SetRenderOptionAction } from '@kieler/klighd-core' import { diagramType } from '@kieler/klighd-core/lib/base/external-helpers' import { Action, ActionMessage, isAction } from 'sprotty-protocol' import { registerLspEditCommands } from 'sprotty-vscode' @@ -58,6 +58,8 @@ export function activate(context: vscode.ExtensionContext): void { ) return } + // add color preferences to the client's init message + setColorTheme(client) const storageService = new StorageService(mementoForPersistence, client) client.onDidChangeState((stateChangedEvent) => { if (stateChangedEvent.newState === State.Running) { @@ -194,15 +196,70 @@ function isLanguageClient(client: unknown): client is LanguageClient { function isFileEndingsArray(array: unknown): array is string[] { return Array.isArray(array) && array.every((val) => typeof val === 'string') } + +/** + * Modify the initialization options to send VSCode's current theme. + */ +function setColorTheme(client: LanguageClient) { + const kind = convertColorThemeKind(vscode.window.activeColorTheme.kind) + // const foreground = new vscode.ThemeColor('editor.foreground') + // const background = new vscode.ThemeColor('editor.background') + // const highlight = new vscode.ThemeColor('focusBorder') + // there is no API to get the color of the current theme for these colors, so just hardcode these here. + // from https://github.com/microsoft/vscode/blob/main/extensions/theme-defaults/themes/light_vs.json + // and https://github.com/microsoft/vscode/blob/main/extensions/theme-defaults/themes/light_modern.json + let foreground = '#000000' // editor.foreground + let background = '#FFFFFF' // editor.background + let highlight = '#005FB8' // focusBorder + if (kind === ColorThemeKind.DARK || kind === ColorThemeKind.HIGH_CONTRAST_DARK) { + // from https://github.com/microsoft/vscode/blob/main/extensions/theme-defaults/themes/dark_vs.json + // and https://github.com/microsoft/vscode/blob/main/extensions/theme-defaults/themes/dark_modern.json + foreground = '#D4D4D4' // editor.foreground + background = '#1E1E1E' // editor.background + highlight = '#0078D4' // focusBorder + } + + // Register the current theme in the client's options. + client.clientOptions.initializationOptions = { + ...client.clientOptions.initializationOptions, + clientColorPreferences: { + kind, + foreground, + background, + highlight, + }, + } +} + /** * Hook into VS Code's theme change and notify the webview to check the current colors and send them to the server. */ function registerChangeColorTheme(manager: KLighDWebviewPanelManager) { - vscode.window.onDidChangeActiveColorTheme(() => { + // Any future color change should be sent to the KLighD webviews. + vscode.window.onDidChangeActiveColorTheme((e: vscode.ColorTheme) => { for (const endpoint of manager.endpoints) { - endpoint.sendAction({ - kind: ChangeColorThemeAction.KIND, - }) + endpoint.sendAction(ChangeColorThemeAction.create(convertColorThemeKind(e.kind))) } }) } + +/** + * Convert the vscode.ColorThemeKind to KLighDs own ColorThemeKind. + * @param kind VS Code's ColorThemeKind + * @returns KLighD'S ColorThemeKind + */ +function convertColorThemeKind(kind: vscode.ColorThemeKind): ColorThemeKind { + switch (kind) { + case vscode.ColorThemeKind.Light: + return ColorThemeKind.LIGHT + case vscode.ColorThemeKind.Dark: + return ColorThemeKind.DARK + case vscode.ColorThemeKind.HighContrast: + return ColorThemeKind.HIGH_CONTRAST_DARK + case vscode.ColorThemeKind.HighContrastLight: + return ColorThemeKind.HIGH_CONTRAST_LIGHT + default: + console.error('error in extension.ts, unknown color theme kind') + return ColorThemeKind.LIGHT + } +} diff --git a/packages/klighd-core/src/actions/actions.ts b/packages/klighd-core/src/actions/actions.ts index 29ae2e5a..6cb995bf 100644 --- a/packages/klighd-core/src/actions/actions.ts +++ b/packages/klighd-core/src/actions/actions.ts @@ -106,14 +106,16 @@ export namespace CheckedImagesAction { */ export interface ChangeColorThemeAction extends Action { kind: typeof ChangeColorThemeAction.KIND + themeKind: ColorThemeKind } export namespace ChangeColorThemeAction { export const KIND = 'changeColorTheme' - export function create(): ChangeColorThemeAction { + export function create(themeKind: ColorThemeKind): ChangeColorThemeAction { return { kind: KIND, + themeKind, } } } @@ -138,13 +140,36 @@ export namespace ClientColorPreferencesAction { } } +/** + * Kinds of color themes, as an enum similar to VS Code's ColorThemeKind. + */ +export enum ColorThemeKind { + /** + * Light color theme with light backgrounds and darker writing + */ + LIGHT = 0, + /** + * Dark color theme with dark backgrounds and lighter writing + */ + DARK = 1, + /** + * Light color theme with a higher contrast. + */ + HIGH_CONTRAST_LIGHT = 2, + /** + * Dark color theme with a higher contrast. + */ + HIGH_CONTRAST_DARK = 3, +} + /** * The color preferences data class, indicating diagram colors to be used by syntheses. */ export interface ColorPreferences { - foreground: string - background: string - highlight: string + kind: ColorThemeKind + foreground: string | undefined + background: string | undefined + highlight: string | undefined } /** diff --git a/packages/klighd-core/src/diagram-server.ts b/packages/klighd-core/src/diagram-server.ts index 0a2b72a5..a81d0c6b 100644 --- a/packages/klighd-core/src/diagram-server.ts +++ b/packages/klighd-core/src/diagram-server.ts @@ -68,6 +68,7 @@ import { CheckedImagesAction, CheckImagesAction, ClientColorPreferencesAction, + ColorThemeKind, KlighdExportSvgAction, KlighdFitToScreenAction, Pair, @@ -245,25 +246,6 @@ export class KlighdDiagramServer extends DiagramServerProxy { } handle(action: Action): void | ICommand | Action { - if (action.kind === RequestModelAction.KIND && getComputedStyle !== undefined) { - // On any request model action, also send the current colors with the request, so the initial - // syntheses can use the theming of VS Code. Values will be undefined outside of VS Code and should - // be ignored. - ;(action as RequestModelAction).options = { - ...(action as RequestModelAction).options, - clientColorPreferenceForeground: getComputedStyle(document.documentElement).getPropertyValue( - '--vscode-editor-foreground' - ), - clientColorPreferenceBackground: getComputedStyle(document.documentElement).getPropertyValue( - '--vscode-editor-background' - ), - clientColorPreferenceHighlight: getComputedStyle(document.documentElement).getPropertyValue( - '--vscode-focusBorder' - ), - } - super.handle(action) - } - if (action.kind === BringToFrontAction.KIND || action.kind === SwitchEditModeAction.KIND) { // Actions that should be ignored and not further handled by this diagram server return @@ -272,7 +254,7 @@ export class KlighdDiagramServer extends DiagramServerProxy { if (action.kind === CheckImagesAction.KIND) { this.handleCheckImages(action as CheckImagesAction) } else if (action.kind === ChangeColorThemeAction.KIND) { - this.handleChangeColorTheme() + this.handleChangeColorTheme((action as ChangeColorThemeAction).themeKind) } else if (action.kind === StoreImagesAction.KIND) { this.handleStoreImages(action as StoreImagesAction) } else if (action.kind === RequestPopupModelAction.KIND) { @@ -302,10 +284,11 @@ export class KlighdDiagramServer extends DiagramServerProxy { this.actionDispatcher.dispatch(CheckedImagesAction.create(notCached)) } - handleChangeColorTheme(): void { + handleChangeColorTheme(kind: ColorThemeKind): void { if (getComputedStyle === undefined) return this.actionDispatcher.dispatch( ClientColorPreferencesAction.create({ + kind, foreground: getComputedStyle(document.documentElement).getPropertyValue('--vscode-editor-foreground'), background: getComputedStyle(document.documentElement).getPropertyValue('--vscode-editor-background'), highlight: getComputedStyle(document.documentElement).getPropertyValue('--vscode-focusBorder'), diff --git a/packages/klighd-core/src/model-viewer.ts b/packages/klighd-core/src/model-viewer.ts index d49c4a07..c59ecba2 100644 --- a/packages/klighd-core/src/model-viewer.ts +++ b/packages/klighd-core/src/model-viewer.ts @@ -15,12 +15,12 @@ * SPDX-License-Identifier: EPL-2.0 */ -import { inject, injectable, postConstruct } from 'inversify' +import { inject, injectable } from 'inversify' import { VNode } from 'snabbdom' import { ModelViewer } from 'sprotty' import { KlighdFitToScreenAction } from './actions/actions' import { DISymbol } from './di.symbols' -import { ForceLightBackground, RenderOptionsRegistry, ResizeToFit } from './options/render-options-registry' +import { RenderOptionsRegistry, ResizeToFit } from './options/render-options-registry' /* global document */ /** @@ -38,22 +38,6 @@ export class KlighdModelViewer extends ModelViewer { @inject(DISymbol.RenderOptionsRegistry) private renderOptionsRegistry: RenderOptionsRegistry - @postConstruct() - init(): void { - // Most diagrams are not rendered with different themes in mind. In case - // a diagram is hard to read, the user can force a light background. - // This toggles such background if the user selects it. - this.renderOptionsRegistry.onChange(() => { - const baseDiv = document.querySelector(`#${this.options.baseDiv}`) - - if (this.renderOptionsRegistry.getValue(ForceLightBackground)) { - baseDiv?.classList.add('light-bg') - } else { - baseDiv?.classList.remove('light-bg') - } - }) - } - protected override onWindowResize(vdom: VNode): void { const baseDiv = document.getElementById(this.options.baseDiv) if (baseDiv !== null) { diff --git a/packages/klighd-core/src/options/render-options-registry.ts b/packages/klighd-core/src/options/render-options-registry.ts index 77c6f3d2..dfd90688 100644 --- a/packages/klighd-core/src/options/render-options-registry.ts +++ b/packages/klighd-core/src/options/render-options-registry.ts @@ -74,31 +74,6 @@ export class ResizeToFit implements RenderOption { debug = true } -/** - * Uses a light background instead of an applied theme. - */ -export class ForceLightBackground implements RenderOption { - static readonly ID: string = 'force-light-background' - - static readonly NAME: string = 'Use Light Background' - - static readonly DEFAULT: boolean = false - - readonly id: string = ForceLightBackground.ID - - readonly name: string = ForceLightBackground.NAME - - readonly type: TransformationOptionType = TransformationOptionType.CHECK - - readonly initialValue: boolean = ForceLightBackground.DEFAULT - - readonly renderCategory: string = Appearance.ID - - readonly description = 'Use light background regardless of the color scheme.' - - currentValue = ForceLightBackground.DEFAULT -} - export class ShowConstraintOption implements RenderOption { static readonly ID: string = 'show-constraints' @@ -541,7 +516,6 @@ export class RenderOptionsRegistry extends Registry { // Appearance this.register(Appearance) - this.register(ForceLightBackground) this.register(ShowConstraintOption) this.register(Shadows) diff --git a/packages/klighd-core/src/views.tsx b/packages/klighd-core/src/views.tsx index 81cb6a5e..3058913c 100644 --- a/packages/klighd-core/src/views.tsx +++ b/packages/klighd-core/src/views.tsx @@ -3,7 +3,7 @@ * * http://rtsys.informatik.uni-kiel.de/kieler * - * Copyright 2019-2023 by + * Copyright 2019-2024 by * + Kiel University * + Department of Computer Science * + Real-Time and Embedded Systems Group @@ -87,8 +87,19 @@ export class SKGraphView implements IView { } const transform = `scale(${model.zoom}) translate(${-model.scroll.x},${-model.scroll.y})` + // Look for a synthesis-defined custom background color. If none is found, use 'white' as a + // default, assuming the synthesis does not know about theming. + let background = 'white' + if ((model as any).properties && (model as any).properties['klighd.diagramBackground'] !== undefined) { + const theBackground = (model as any).properties['klighd.diagramBackground'] + const r = theBackground.red ? theBackground.red : 0 + const g = theBackground.green ? theBackground.green : 0 + const b = theBackground.blue ? theBackground.blue : 0 + background = `rgb(${r},${g},${b})` + } + return ( - + {context.renderChildren(model)} ) diff --git a/packages/klighd-core/styles/theme.css b/packages/klighd-core/styles/theme.css index 6eb89f0b..b9c59074 100644 --- a/packages/klighd-core/styles/theme.css +++ b/packages/klighd-core/styles/theme.css @@ -3,7 +3,7 @@ * * http://rtsys.informatik.uni-kiel.de/kieler * - * Copyright 2021 by + * Copyright 2021-2024 by * + Kiel University * + Department of Computer Science * + Real-Time and Embedded Systems Group @@ -35,4 +35,18 @@ --kdc-color-sidebar-font-primary: hsl(0, 0%, 12%); --kdc-color-sidebar-icon-primary: hsl(0, 0%, 24%); --kdc-color-primary: #0552b5; + +} +@media (prefers-color-scheme: dark) { + :root { + --kdc-color-sidebar-background: rgb(37, 37, 37); + --kdc-color-sidebar-trigger-background: rgb(37, 37, 37); + --kdc-color-sidebar-trigger-background-hover: rgb(4, 57, 94); + --kdc-color-sidebar-trigger-background-active: rgb(55, 55, 61); + --kdc-color-sidebar-hover-background: rgba(90, 93, 94, 0.31); + --kdc-color-sidebar-font-primary: rgb(204, 204, 204); + --kdc-color-sidebar-icon-primary: rgb(197, 197, 197); + --kdc-color-primary: rgb(0, 127, 212); + + } }