Skip to content

Commit

Permalink
[3933] Fix explorer in vscode extension
Browse files Browse the repository at this point in the history
Bug: #3933
Signed-off-by: Michaël Charfadi <[email protected]>
  • Loading branch information
mcharfadi committed Sep 2, 2024
1 parent f12f3e1 commit b440e9f
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ As a result, the following maven modules have been deleted: `sirius-web-sample-a
- https://github.com/eclipse-sirius/sirius-web/issues/3878[#3878] [diagram] Unmount ReactFlowProvider after layout
- https://github.com/eclipse-sirius/sirius-web/issues/3869[#3869] [form] Close form-based views when the underlying element no longer exists.
- https://github.com/eclipse-sirius/sirius-web/issues/3899[#3899] [diagram] Fix an issue when using alt-tab shortcut and trying to drag a node afterwards
- https://github.com/eclipse-sirius/sirius-web/issues/3933[#3933] [vs-code] Fix explorer in vscode extension

=== New Features

Expand Down
18 changes: 14 additions & 4 deletions vscode-extension/src/data/ProjectData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/

import axios from 'axios';
import { v4 as uuid } from 'uuid';
import { commands, window } from 'vscode';
import { w3cwebsocket as W3CWebSocket } from 'websocket';
import { ModelData } from './ModelData';
import { GQLGetRepresentationMetadataResponse } from './ProjectData.types';
import { GQLGetRepresentationMetadataResponse, GQLStyledString } from './ProjectData.types';
import { RepresentationData } from './RepresentationData';
import { getTreeEventSubscription } from './getTreeEventSubscription';

const getTextFromStyledString = (styledString: GQLStyledString): string => {
return styledString.styledStringFragments.map((fragments) => fragments.text).join();
};

export class ProjectData {
private modelsData: ModelData[];
private representationsData: RepresentationData[];
Expand Down Expand Up @@ -104,9 +107,16 @@ export class ProjectData {
private buildModelData(elements: []): ModelData[] {
const modelsData: ModelData[] = [];
elements.forEach(
(element: { id: string; label: string; kind: string; imageURL: string; hasChildren: boolean; children: [] }) => {
(element: {
id: string;
label: GQLStyledString;
kind: string;
imageURL: string;
hasChildren: boolean;
children: [];
}) => {
if (!this.isHandledRepresentation(element)) {
let elementLabel = element.label;
let elementLabel = getTextFromStyledString(element.label);
if (elementLabel === undefined || elementLabel.length === 0) {
elementLabel = String(element.kind.split('::').pop());
}
Expand Down
34 changes: 33 additions & 1 deletion vscode-extension/src/data/ProjectData.types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023 Obeo.
* Copyright (c) 2023, 2024 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -40,3 +40,35 @@ export interface GQLGetRepresentationMetadataRepresentationMetadata {
label: string;
kind: string;
}

export interface GQLStyledString {
styledStringFragments: GQLStyledStringFragment[];
}
export interface GQLStyledStringFragment {
text: string;
styledStringFragmentStyle: GQLStyledStringFragmentStyle;
}
export interface GQLStyledStringFragmentStyle {
font: string;
backgroundColor: string;
foregroundColor: string;
isStruckOut: boolean;
strikeoutColor: string;
underlineColor: string;
borderColor: string;
borderStyle: GQLBorderStyle;
underlineStyle: GQLUnderLineStyle;
}
export type GQLUnderLineStyle = 'NONE' | 'SOLID' | 'DOUBLE' | 'DOTTED' | 'DASHED' | 'WAVY';

export type GQLBorderStyle =
| 'NONE'
| 'HIDDEN'
| 'DOTTED'
| 'DASHED'
| 'SOLID'
| 'DOUBLE'
| 'GROOVE'
| 'RIDGE'
| 'INSET'
| 'OUTSET';
20 changes: 18 additions & 2 deletions vscode-extension/src/data/getTreeEventSubscription.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022, 2023 Obeo.
* Copyright (c) 2022, 2024 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -37,9 +37,25 @@ fragment treeItemFields on TreeItem {
id
hasChildren
expanded
label
label {
styledStringFragments {
text
styledStringFragmentStyle {
isStruckOut
underlineStyle
borderStyle
font
backgroundColor
foregroundColor
strikeoutColor
underlineColor
borderColor
}
}
}
editable
deletable
selectable
kind
iconURL
}
Expand Down

0 comments on commit b440e9f

Please sign in to comment.