Skip to content

Commit 99c2415

Browse files
committed
[3981] Display the diagram palette tools and tool sections in a list
Bug: #3981 Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
1 parent 10bbd23 commit 99c2415

File tree

30 files changed

+1365
-751
lines changed

30 files changed

+1365
-751
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ never, always and if_children (to display the separator only if children exist).
8181
+ Make possible to register view models in the loading editing context when the "test" profile is active.
8282
+ To activate the test profile add the value _test_ to the `SPRING_PROFILES_ACTIVE` environment variable.
8383
- https://github.com/eclipse-sirius/sirius-web/issues/3882[#3882] [sirius-web] Add a new tree event to handle tree description which are not explorer-related
84+
- https://github.com/eclipse-sirius/sirius-web/issues/3981[#3981] [diagram] Update the design and capabilities of the contextual palette
8485

8586
== v2024.9.0
8687

package-lock.json

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compatibility/backend/sirius-components-compatibility/src/main/java/org/eclipse/sirius/components/compatibility/services/diagrams/CompatibilityPaletteProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.eclipse.emf.ecore.EObject;
2424
import org.eclipse.sirius.components.collaborative.diagrams.api.DiagramImageConstants;
2525
import org.eclipse.sirius.components.collaborative.diagrams.api.IPaletteProvider;
26+
import org.eclipse.sirius.components.collaborative.diagrams.dto.IPaletteEntry;
2627
import org.eclipse.sirius.components.collaborative.diagrams.dto.ITool;
2728
import org.eclipse.sirius.components.collaborative.diagrams.dto.Palette;
2829
import org.eclipse.sirius.components.collaborative.diagrams.dto.SingleClickOnDiagramElementTool;
@@ -95,7 +96,7 @@ public Palette handle(Object targetElement, Object diagramElement, Object diagra
9596
.map(org.eclipse.sirius.diagram.description.DiagramDescription.class::cast)
9697
.findFirst();
9798

98-
List<ToolSection> toolSections = new ArrayList<>();
99+
List<IPaletteEntry> toolSections = new ArrayList<>();
99100
if (optionalSiriusDiagramDescription.isPresent()) {
100101
org.eclipse.sirius.diagram.description.DiagramDescription siriusDiagramDescription = optionalSiriusDiagramDescription.get();
101102
List<ToolSection> filteredToolSections = this.getToolSectionFromDiagramDescriptionToolSection(diagramDescription).stream()
@@ -107,7 +108,7 @@ public Palette handle(Object targetElement, Object diagramElement, Object diagra
107108
toolSections.addAll(this.createExtraToolSections(diagramElementDescription));
108109
}
109110
String paletteId = "siriusComponents://palette?diagramId=" + optionalVsmElementId.get();
110-
return Palette.newPalette(paletteId).tools(List.of()).toolSections(toolSections).build();
111+
return Palette.newPalette(paletteId).quickAccessTools(List.of()).paletteEntries(toolSections).build();
111112
}
112113

113114
private List<ToolSection> getToolSectionFromDiagramDescriptionToolSection(DiagramDescription diagramDescription) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 Obeo.
3+
* This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Obeo - initial API and implementation
12+
*******************************************************************************/
13+
package org.eclipse.sirius.components.collaborative.diagrams.dto;
14+
15+
/**
16+
* The common interface for elements displayed in the palette.
17+
* @author fbarbin
18+
*/
19+
public interface IPaletteEntry {
20+
21+
String id();
22+
}

packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/ITool.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2023 Obeo.
2+
* Copyright (c) 2023, 2024 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -19,9 +19,7 @@
1919
*
2020
* @author mcharfadi
2121
*/
22-
public interface ITool {
23-
24-
String id();
22+
public interface ITool extends IPaletteEntry {
2523

2624
String label();
2725

packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/Palette.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2023 Obeo.
2+
* Copyright (c) 2023, 2024 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -20,12 +20,12 @@
2020
*
2121
* @author frouene
2222
*/
23-
public record Palette(String id, List<ITool> tools, List<ToolSection> toolSections) {
23+
public record Palette(String id, List<ITool> quickAccessTools, List<IPaletteEntry> paletteEntries) {
2424

2525
public Palette {
2626
Objects.requireNonNull(id);
27-
Objects.requireNonNull(tools);
28-
Objects.requireNonNull(toolSections);
27+
Objects.requireNonNull(quickAccessTools);
28+
Objects.requireNonNull(paletteEntries);
2929
}
3030

3131
public static Builder newPalette(String id) {
@@ -43,26 +43,26 @@ public static final class Builder {
4343

4444
private final String id;
4545

46-
private List<ITool> tools;
46+
private List<ITool> quickAccessTools;
4747

48-
private List<ToolSection> toolSections;
48+
private List<IPaletteEntry> paletteEntries;
4949

5050
private Builder(String id) {
5151
this.id = Objects.requireNonNull(id);
5252
}
5353

54-
public Builder tools(List<ITool> tools) {
55-
this.tools = Objects.requireNonNull(tools);
54+
public Builder quickAccessTools(List<ITool> quickAccessTools) {
55+
this.quickAccessTools = Objects.requireNonNull(quickAccessTools);
5656
return this;
5757
}
5858

59-
public Builder toolSections(List<ToolSection> toolSections) {
60-
this.toolSections = Objects.requireNonNull(toolSections);
59+
public Builder paletteEntries(List<IPaletteEntry> paletteEntries) {
60+
this.paletteEntries = Objects.requireNonNull(paletteEntries);
6161
return this;
6262
}
6363

6464
public Palette build() {
65-
return new Palette(this.id, this.tools, this.toolSections);
65+
return new Palette(this.id, this.quickAccessTools, this.paletteEntries);
6666
}
6767
}
6868

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 Obeo.
3+
* This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Obeo - initial API and implementation
12+
*******************************************************************************/
13+
package org.eclipse.sirius.components.collaborative.diagrams.dto;
14+
15+
import java.util.Objects;
16+
17+
/**
18+
* Represents a divider between tools or tool sections in the palette.
19+
* @author fbarbin
20+
*/
21+
public record PaletteDivider(String id) implements IPaletteEntry {
22+
23+
public PaletteDivider {
24+
Objects.requireNonNull(id);
25+
}
26+
}

packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/java/org/eclipse/sirius/components/collaborative/diagrams/dto/ToolSection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2023 Obeo.
2+
* Copyright (c) 2023, 2024 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -20,7 +20,7 @@
2020
*
2121
* @author mcharfadi
2222
*/
23-
public record ToolSection(String id, String label, List<String> iconURL, List<ITool> tools) {
23+
public record ToolSection(String id, String label, List<String> iconURL, List<ITool> tools) implements IPaletteEntry {
2424

2525
public ToolSection {
2626
Objects.requireNonNull(id);

packages/diagrams/backend/sirius-components-collaborative-diagrams/src/main/resources/schema/diagram.graphqls

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,18 @@ type Size {
260260

261261
type Palette {
262262
id: ID!
263-
tools: [Tool]!
264-
toolSections: [ToolSection]!
263+
quickAccessTools: [Tool]!
264+
paletteEntries: [PaletteEntry]!
265+
}
266+
267+
union PaletteEntry =
268+
ToolSection
269+
| SingleClickOnDiagramElementTool
270+
| SingleClickOnTwoDiagramElementsTool
271+
| PaletteDivider
272+
273+
type PaletteDivider {
274+
id: ID!
265275
}
266276

267277
type ToolSection {

packages/diagrams/backend/sirius-components-diagrams-tests/src/main/java/org/eclipse/sirius/components/diagrams/tests/graphql/PaletteQueryRunner.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,18 @@ query getPalette($editingContextId: ID!, $representationId: ID!, $diagramElement
3636
... on DiagramDescription {
3737
palette(diagramElementId: $diagramElementId) {
3838
id
39-
tools {
39+
quickAccessTools {
4040
...ToolFields
4141
}
42-
toolSections {
43-
id
44-
label
45-
iconURL
46-
tools {
47-
...ToolFields
42+
paletteEntries {
43+
...ToolFields
44+
... on ToolSection {
45+
id
46+
label
47+
iconURL
48+
tools {
49+
...ToolFields
50+
}
4851
}
4952
}
5053
}

packages/diagrams/frontend/sirius-components-diagrams/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ export type { NodeContextValue } from './renderer/node/NodeContext.types';
5757
export { NodeTypeContribution } from './renderer/node/NodeTypeContribution';
5858
export type { DiagramNodeType } from './renderer/node/NodeTypes.types';
5959
export { DiagramElementPalette } from './renderer/palette/DiagramElementPalette';
60-
export type { DiagramPaletteToolContributionComponentProps } from './renderer/palette/DiagramPaletteToolContribution.types';
60+
export type {
61+
DiagramPaletteToolContributionComponentProps,
62+
DiagramPaletteToolContributionProps,
63+
} from './renderer/palette/DiagramPaletteToolContribution.types';
6164
export type { GQLToolVariable, GQLToolVariableType } from './renderer/palette/Palette.types';
6265
export type { DiagramPaletteToolComponentProps } from './renderer/palette/tool/DiagramPaletteTool.types';
6366
export { diagramPaletteToolExtensionPoint } from './renderer/palette/tool/DiagramPaletteToolExtensionPoints';

packages/diagrams/frontend/sirius-components-diagrams/src/renderer/connector/useConnector.types.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,24 @@ export interface GQLDiagramDescription extends GQLRepresentationDescription {
5959

6060
export interface GQLPalette {
6161
id: string;
62+
paletteEntries: GQLPaletteEntry[];
63+
}
64+
65+
export interface GQLPaletteEntry {
66+
id: string;
67+
__typename: string;
68+
}
69+
export interface GQLPaletteDivider extends GQLPaletteEntry {}
70+
71+
export interface GQLToolSection extends GQLPaletteEntry {
72+
label: string;
73+
iconURL: string[];
6274
tools: GQLTool[];
63-
toolSections: GQLToolSection[];
6475
}
6576

6677
export interface GQLToolSection {
6778
id: string;
6879
label: string;
69-
imageURL: string;
7080
tools: GQLTool[];
7181
__typename: string;
7282
}

0 commit comments

Comments
 (0)