diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 7c9cb66fe3..920fc743d5 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -35,7 +35,9 @@ This may have some consequences for downstream applications which are embedding - https://github.com/eclipse-sirius/sirius-web/issues/4356[#4356] [diagram] Add a minimap to diagram. + Added by default to all sirius-web diagrams - https://github.com/eclipse-sirius/sirius-web/issues/4346[#4346] [query] Add support for a query view. -Specifiers can contribute dedicated AQL services for this feature using implementations of `IInterpreterJavaServiceProvider`. +Specifiers can contribute dedicated AQL services for this feature using implementations of `IInterpreterJavaServiceProvider` +- https://github.com/eclipse-sirius/sirius-web/issues/4346[#4346] [core] The field `Object#iconURLs` has been added to the GraphQL schema in order to retrieve the icon of an object +- https://github.com/eclipse-sirius/sirius-web/issues/4346[#4346] [query] Add some feedback for long running evaluations === Improvements diff --git a/packages/core/backend/sirius-components-collaborative/src/main/resources/schema/core.graphqls b/packages/core/backend/sirius-components-collaborative/src/main/resources/schema/core.graphqls index 1f8862b495..02e8367008 100644 --- a/packages/core/backend/sirius-components-collaborative/src/main/resources/schema/core.graphqls +++ b/packages/core/backend/sirius-components-collaborative/src/main/resources/schema/core.graphqls @@ -172,6 +172,7 @@ type Object { id: ID! kind: String! label: String! + iconURLs: [String!]! queryBasedString(query: String!): String queryBasedInt(query: String!): Int queryBasedBoolean(query: String!): Boolean diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/object/controllers/ObjectIconURLsDataFetcher.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/object/controllers/ObjectIconURLsDataFetcher.java new file mode 100644 index 0000000000..aa950014eb --- /dev/null +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/object/controllers/ObjectIconURLsDataFetcher.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2025 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 + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.web.application.object.controllers; + +import java.util.List; +import java.util.Objects; + +import org.eclipse.sirius.components.annotations.spring.graphql.QueryDataFetcher; +import org.eclipse.sirius.components.core.api.IImageURLSanitizer; +import org.eclipse.sirius.components.core.api.ILabelService; +import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates; +import org.eclipse.sirius.components.graphql.api.URLConstants; + +import graphql.schema.DataFetchingEnvironment; + +/** + * The data fetcher for the field Object#iconURLs. + * + * @author sbegaudeau + */ +@QueryDataFetcher(type = "Object", field = "iconURLs") +public class ObjectIconURLsDataFetcher implements IDataFetcherWithFieldCoordinates> { + + private final IImageURLSanitizer imageURLSanitizer; + + private final ILabelService labelService; + + public ObjectIconURLsDataFetcher(IImageURLSanitizer imageURLSanitizer, ILabelService labelService) { + this.imageURLSanitizer = Objects.requireNonNull(imageURLSanitizer); + this.labelService = Objects.requireNonNull(labelService); + } + + @Override + public List get(DataFetchingEnvironment environment) throws Exception { + var object = environment.getSource(); + + return this.labelService.getImagePath(object).stream() + .map(url -> this.imageURLSanitizer.sanitize(URLConstants.IMAGE_BASE_PATH, url)) + .toList(); + } +} diff --git a/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/workbench-views/query/QueryView.tsx b/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/workbench-views/query/QueryView.tsx index 4a56955e28..e31264a90e 100644 --- a/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/workbench-views/query/QueryView.tsx +++ b/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/workbench-views/query/QueryView.tsx @@ -10,14 +10,16 @@ * Contributors: * Obeo - initial API and implementation *******************************************************************************/ -import { WorkbenchViewComponentProps } from '@eclipse-sirius/sirius-components-core'; +import { IconOverlay, WorkbenchViewComponentProps } from '@eclipse-sirius/sirius-components-core'; import PlayCircleOutlineIcon from '@mui/icons-material/PlayCircleOutline'; import Box from '@mui/material/Box'; import IconButton from '@mui/material/IconButton'; import List from '@mui/material/List'; import ListItem from '@mui/material/ListItem'; +import ListItemIcon from '@mui/material/ListItemIcon'; import ListItemText from '@mui/material/ListItemText'; -import { SxProps, Theme } from '@mui/material/styles'; +import Skeleton from '@mui/material/Skeleton'; +import { SxProps, Theme, useTheme } from '@mui/material/styles'; import TextField from '@mui/material/TextField'; import Typography from '@mui/material/Typography'; import { ComponentType, useState } from 'react'; @@ -51,7 +53,7 @@ export const QueryView = ({ editingContextId, readOnly }: WorkbenchViewComponent return ( - + ); }; @@ -117,13 +119,23 @@ const ObjectExpressionResultViewer = ({ result }: ExpressionResultViewerProps) = } const { objectValue } = result as GQLObjectExpressionResult; + + const listItemStyle: SxProps = (theme) => ({ + gap: theme.spacing(2), + }); + const listItemIconStyle: SxProps = () => ({ + minWidth: '0px', + }); return ( - One object returned + One object has been returned - + + + + @@ -137,15 +149,25 @@ const ObjectsExpressionResultViewer = ({ result }: ExpressionResultViewerProps) } const { objectsValue } = result as GQLObjectsExpressionResult; + + const listItemStyle: SxProps = (theme) => ({ + gap: theme.spacing(2), + }); + const listItemIconStyle: SxProps = () => ({ + minWidth: '0px', + }); return ( - {objectsValue.length} object(s) returned + A collection of {objectsValue.length} object{objectsValue.length > 1 ? 's' : ''} has been returned {objectsValue.map((object) => { return ( - + + + + ); @@ -164,7 +186,7 @@ const BooleanExpressionResultViewer = ({ result }: ExpressionResultViewerProps) return ( - One boolean returned + One boolean has been returned @@ -184,7 +206,7 @@ const StringExpressionResultViewer = ({ result }: ExpressionResultViewerProps) = return ( - One string returned + One string has been returned @@ -204,7 +226,7 @@ const IntExpressionResultViewer = ({ result }: ExpressionResultViewerProps) => { return ( - One integer returned + One integer has been returned @@ -223,7 +245,38 @@ const resultType2viewer: Record { +const LoadingViewer = () => { + const theme = useTheme(); + + const listItemStyle: SxProps = (theme) => ({ + gap: theme.spacing(2), + }); + const skeletonTextStyle: SxProps = (theme) => ({ + fontSize: theme.typography.body1.fontSize, + width: '60%', + }); + return ( + + + + + + + + + + + + + + + + + + ); +}; + +const ResultArea = ({ loading, payload }: ResultAreaProps) => { const resultAreaToolbarStyle: SxProps = { display: 'flex', flexDirection: 'row', @@ -237,7 +290,9 @@ const ResultArea = ({ payload }: ResultAreaProps) => { }; let content: JSX.Element | null = null; - if (payload) { + if (loading) { + content = ; + } else if (payload) { const Viewer = resultType2viewer[payload.result.__typename]; if (Viewer) { content = ; diff --git a/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/workbench-views/query/QueryView.types.ts b/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/workbench-views/query/QueryView.types.ts index 16c0226c08..ed41352146 100644 --- a/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/workbench-views/query/QueryView.types.ts +++ b/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/workbench-views/query/QueryView.types.ts @@ -23,6 +23,7 @@ export interface ExpressionAreaState { } export interface ResultAreaProps { + loading: boolean; payload: GQLEvaluateExpressionSuccessPayload | null; } diff --git a/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/workbench-views/query/useEvaluateExpression.tsx b/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/workbench-views/query/useEvaluateExpression.tsx index 7dac699d14..590d4a9a70 100644 --- a/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/workbench-views/query/useEvaluateExpression.tsx +++ b/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/workbench-views/query/useEvaluateExpression.tsx @@ -35,6 +35,7 @@ const evaluateExpressionMutation = gql` id kind label + iconURLs } } ... on ObjectsExpressionResult { @@ -42,6 +43,7 @@ const evaluateExpressionMutation = gql` id kind label + iconURLs } } ... on BooleanExpressionResult { diff --git a/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/workbench-views/query/useEvaluateExpression.types.ts b/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/workbench-views/query/useEvaluateExpression.types.ts index 6f6389ded4..4265121a82 100644 --- a/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/workbench-views/query/useEvaluateExpression.types.ts +++ b/packages/sirius-web/frontend/sirius-web-application/src/views/edit-project/workbench-views/query/useEvaluateExpression.types.ts @@ -43,6 +43,7 @@ export interface GQLObject { id: string; kind: string; label: string; + iconURLs: string[]; } export interface GQLObjectsExpressionResult extends GQLExpressionResult {