Skip to content

Commit

Permalink
[2796] Convert flow to view DSL
Browse files Browse the repository at this point in the history
Bug: #2796
Signed-off-by: Florian ROUËNÉ <florian.rouene@obeosoft.com>
  • Loading branch information
frouene committed Jan 10, 2024
1 parent 992c736 commit 300d2f5
Show file tree
Hide file tree
Showing 78 changed files with 3,804 additions and 198 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Additional changes to this interface will propably occur in the near future in o
- https://github.com/eclipse-sirius/sirius-web/issues/2889[#2889] [emf] Remove the default implementation of the editing context from the `sirius-components-emf` module.
The default implementation of the editing context for Sirius Web, which had Sirius Web specific code already, will be owned by `sirius-web-services`.
This default implementation will now also contain all the view models properly loaded which should be considered during the lifecycle of the editing context.
- https://github.com/eclipse-sirius/sirius-web/issues/2796[#2796] [sirius-web] All Flow related configurations have been moved to `sirius-components-flow-starter` module.

=== Dependency update

Expand Down Expand Up @@ -149,7 +150,7 @@ After this change, we will be able to delete the `EditingContext` class from `si
Among those capabilities, we should find the list of view models to consider during the lifecycle of the editing context.
- https://github.com/eclipse-sirius/sirius-web/issues/2889[#2889] [view] Load view models only once during the lifecycle of the editing context.
This change makes the editing context the single source of truth for the state of the view models.

- https://github.com/eclipse-sirius/sirius-web/issues/2796[#2796] [sirius-web] Flow diagram description has been converted to the view DSL.

== v2023.12.0

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright (c) 2021, 2023 Obeo.
* Copyright (c) 2021, 2024 Obeo.
* This program and the accompanying materials
* are made available under the erms of the Eclipse Public License v2.0
* 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/
*
Expand All @@ -10,7 +10,9 @@
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
describe('/projects/:projectId/edit - Diagram', () => {
// Flow diagram description does not have selection tools after the view DSL conversion
// These tests can be reactivated when selection support is added to React-Flow
describe.skip('/projects/:projectId/edit - Diagram', () => {
beforeEach(() => {
cy.deleteAllProjects();
cy.createProject('Cypress Project').then((res) => {
Expand Down
3 changes: 1 addition & 2 deletions integration-tests/cypress/e2e/project/diagrams/diagram.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ describe('/projects/:projectId/edit - Diagram', () => {
cy.getByTestId('Topography with auto layout').click();
cy.getByTestId('create-representation').click();

cy.get('#diagram>svg text.sprotty-label').should('have.length', 23);
cy.get('#diagram>svg foreignObject.sprotty-label').should('have.length', 2);
cy.get('#diagram>svg text.sprotty-label').should('have.length', 25);
cy.get('#diagram>svg g.sprotty-edge').should('have.length', 7);
cy.get('#diagram>svg image').should('have.length', 10);
cy.get('#diagram rect').should('have.length', 18);
Expand Down
65 changes: 65 additions & 0 deletions integration-tests/cypress/e2e/project/flow/flow.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*******************************************************************************
* Copyright (c) 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
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/

import { Project } from '../../../pages/Project';
import { Flow } from '../../../usecases/Flow';
import { Explorer } from '../../../workbench/Explorer';
import { Diagram } from '../../../workbench/Diagram';

const projectName = 'Cypress - flow';

describe('Flow', () => {
context('Given a flow project with a robot document', () => {
let projectId: string = '';
beforeEach(() =>
new Flow().createRobotProject(projectName).then((createdProjectData) => {
projectId = createdProjectData.projectId;
new Project().visit(projectId);
})
);

afterEach(() => cy.deleteProject(projectId));

context('When we interact with the flow diagram', () => {
it('Then I can create a topography diagram', () => {
const explorer = new Explorer();
const diagram = new Diagram();
explorer.getExplorerView().contains('robot');
explorer.expand('robot');
explorer.createRepresentation('Robot', 'Topography', 'diagramTopography');
diagram.getDiagram('diagramTopography').should('exist');
diagram.getNodes('diagramTopography', 'Central_Unit').should('exist');
});

it('Then I can create a topography unsynchronized diagram', () => {
const explorer = new Explorer();
const diagram = new Diagram();
explorer.getExplorerView().contains('robot');
explorer.expand('robot');
explorer.createRepresentation('Robot', 'Topography unsynchronized', 'diagramTopographyUnsynchronized');
diagram.getDiagram('diagramTopographyUnsynchronized').should('exist');
diagram.getNodes('diagramTopographyUnsynchronized', 'Central_Unit').should('not.exist');
});

it('Then I can create a topography with auto layout diagram', () => {
const explorer = new Explorer();
const diagram = new Diagram();
explorer.getExplorerView().contains('robot');
explorer.expand('robot');
explorer.createRepresentation('Robot', 'Topography with auto layout', 'diagramTopographyWithAutoLayout');
diagram.getDiagram('diagramTopographyWithAutoLayout').should('exist');
diagram.getNodes('diagramTopographyWithAutoLayout', 'Description').should('exist');
});
});
});
});
35 changes: 12 additions & 23 deletions packages/sirius-web/backend/sirius-web-sample-application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

<properties>
<java.version>17</java.version>
<flow.version>1.0.11-SNAPSHOT</flow.version>
<bpmn.version>4.0.3-SNAPSHOT</bpmn.version>
<eef.version>2.1.5-SNAPSHOT</eef.version>
</properties>
Expand Down Expand Up @@ -156,23 +155,13 @@
</dependency>
<dependency>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-view-deck</artifactId>
<version>2023.12.8</version>
</dependency>
<dependency>
<groupId>fr.obeo.dsl.designer.sample.flow</groupId>
<artifactId>fr.obeo.dsl.designer.sample.flow</artifactId>
<version>${flow.version}</version>
</dependency>
<dependency>
<groupId>fr.obeo.dsl.designer.sample.flow</groupId>
<artifactId>fr.obeo.dsl.designer.sample.flow.edit</artifactId>
<version>${flow.version}</version>
<artifactId>sirius-components-flow-starter</artifactId>
<version>2023.12.8</version>
</dependency>
<dependency>
<groupId>fr.obeo.dsl.designer.sample.flow</groupId>
<artifactId>fr.obeo.dsl.designer.sample.flow.design</artifactId>
<version>${flow.version}</version>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-view-deck</artifactId>
<version>2023.12.8</version>
</dependency>
<dependency>
<groupId>BPMN2</groupId>
Expand Down Expand Up @@ -269,13 +258,13 @@
<version>2023.12.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-view-deck-edit</artifactId>
<version>2023.12.8</version>
<scope>compile</scope>
</dependency>
</dependencies>
<dependency>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-view-deck-edit</artifactId>
<version>2023.12.8</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2023 Obeo.
* Copyright (c) 2019, 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 All @@ -12,16 +12,11 @@
*******************************************************************************/
package org.eclipse.sirius.web.sample.configuration;

import fr.obeo.dsl.designer.sample.flow.FlowPackage;
import fr.obeo.dsl.designer.sample.flow.provider.FlowItemProviderAdapterFactory;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.sirius.components.domain.DomainPackage;
import org.eclipse.sirius.components.domain.provider.DomainItemProviderAdapterFactory;
import org.eclipse.sirius.components.emf.configuration.ChildExtenderProvider;
import org.eclipse.sirius.components.emf.services.ILabelFeatureProvider;
import org.eclipse.sirius.components.emf.services.LabelFeatureProvider;
import org.eclipse.sirius.components.view.ViewPackage;
import org.eclipse.sirius.components.view.diagram.DiagramPackage;
import org.eclipse.sirius.components.view.diagram.provider.DiagramItemProviderAdapterFactory;
Expand All @@ -44,21 +39,6 @@
@Configuration
public class SampleEMFConfiguration {

@Bean
public AdapterFactory flowAdapterFactory() {
return new FlowItemProviderAdapterFactory();
}

@Bean
public EPackage flowEPackage() {
return FlowPackage.eINSTANCE;
}

@Bean
public ILabelFeatureProvider flowLabelFeatureProvider() {
return new LabelFeatureProvider(FlowPackage.eINSTANCE.getNsURI(), new FlowLabelFeatureSwitch(), new FlowEditableSwitch());
}

@Bean
@ConditionalOnProperty(prefix = "org.eclipse.sirius.web.features", name = "studioDefinition")
public EPackage domainEPackage() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2022 Obeo.
* Copyright (c) 2019, 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 @@ -29,7 +29,7 @@ public class SampleSiriusConfiguration implements ISiriusConfiguration {

@Override
public List<String> getODesignPaths() {
return List.of("description/flow.odesign");
return List.of();
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2023 Obeo.
* Copyright (c) 2019, 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 All @@ -12,8 +12,6 @@
*******************************************************************************/
package org.eclipse.sirius.web.sample.configuration;

import fr.obeo.dsl.designer.sample.flow.FlowFactory;

import java.util.List;
import java.util.UUID;

Expand All @@ -30,7 +28,6 @@
import org.eclipse.sirius.web.sample.papaya.view.PapayaViewProvider;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;

import io.micrometer.core.instrument.MeterRegistry;

Expand All @@ -46,18 +43,6 @@ public class StereotypeDescriptionRegistryConfigurer implements IStereotypeDescr

public static final String EMPTY_LABEL = "Others...";

public static final UUID EMPTY_FLOW_ID = UUID.nameUUIDFromBytes("empty_flow".getBytes());

public static final String EMPTY_FLOW_LABEL = "Flow";

public static final UUID ROBOT_FLOW_ID = UUID.nameUUIDFromBytes("robot_flow".getBytes());

public static final String ROBOT_FLOW_LABEL = "Robot Flow";

public static final UUID BIG_GUY_FLOW_ID = UUID.nameUUIDFromBytes("big_guy_flow".getBytes());

public static final String BIG_GUY_FLOW_LABEL = "Big Guy Flow (17k elements)";

public static final UUID EMPTY_VIEW_ID = UUID.nameUUIDFromBytes("empty_view".getBytes());

public static final String EMPTY_VIEW_LABEL = "View";
Expand Down Expand Up @@ -90,15 +75,12 @@ public StereotypeDescriptionRegistryConfigurer(MeterRegistry meterRegistry, @Val

@Override
public void addStereotypeDescriptions(IStereotypeDescriptionRegistry registry) {
registry.add(new StereotypeDescription(EMPTY_FLOW_ID, EMPTY_FLOW_LABEL, this::getEmptyFlowContent));
if (this.studiosEnabled) {
registry.add(new StereotypeDescription(EMPTY_DOMAIN_ID, EMPTY_DOMAIN_LABEL, this::getEmptyDomainContent));
registry.add(new StereotypeDescription(EMPTY_VIEW_ID, EMPTY_VIEW_LABEL, this::getEmptyViewContent));
registry.add(new StereotypeDescription(PAPAYA_DOMAIN_ID, PAPAYA_DOMAIN_LABEL, this::getPapayaDomainContent));
registry.add(new StereotypeDescription(PAPAYA_VIEW_ID, PAPAYA_VIEW_LABEL, this::getPapayaViewContent));
}
registry.add(new StereotypeDescription(ROBOT_FLOW_ID, ROBOT_FLOW_LABEL, this::getRobotFlowContent));
registry.add(new StereotypeDescription(BIG_GUY_FLOW_ID, BIG_GUY_FLOW_LABEL, this::getBigGuyFlowContent));
registry.add(new StereotypeDescription(EMPTY_ID, EMPTY_LABEL, "New", this::getEmptyContent));
}

Expand Down Expand Up @@ -130,15 +112,4 @@ private String getEmptyContent() {
return this.stereotypeBuilder.getStereotypeBody(List.of());
}

private String getEmptyFlowContent() {
return this.stereotypeBuilder.getStereotypeBody(List.of(FlowFactory.eINSTANCE.createSystem()));
}

private String getRobotFlowContent() {
return this.stereotypeBuilder.getStereotypeBody(new ClassPathResource("robot.flow"));
}

private String getBigGuyFlowContent() {
return this.stereotypeBuilder.getStereotypeBody(new ClassPathResource("Big_Guy.flow"));
}
}
Loading

0 comments on commit 300d2f5

Please sign in to comment.