-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2796] Add power node descriptions to Flow view DSL
Bug: #2796 Signed-off-by: Florian ROUËNÉ <florian.rouene@obeosoft.com>
- Loading branch information
Showing
10 changed files
with
192 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...lipse/sirius/components/flow/starter/view/descriptions/PowerInputDescriptionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/******************************************************************************* | ||
* 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 | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.flow.starter.view.descriptions; | ||
|
||
import static org.eclipse.sirius.components.flow.starter.view.FlowViewBuilder.POWER_INPUT_SVG_ID; | ||
|
||
import java.util.Objects; | ||
|
||
import org.eclipse.sirius.components.flow.starter.view.FlowViewBuilder; | ||
import org.eclipse.sirius.components.view.builder.IViewDiagramElementFinder; | ||
import org.eclipse.sirius.components.view.builder.generated.DiagramBuilders; | ||
import org.eclipse.sirius.components.view.builder.providers.IColorProvider; | ||
import org.eclipse.sirius.components.view.builder.providers.INodeDescriptionProvider; | ||
import org.eclipse.sirius.components.view.diagram.DiagramDescription; | ||
import org.eclipse.sirius.components.view.diagram.DiagramFactory; | ||
import org.eclipse.sirius.components.view.diagram.NodeDescription; | ||
import org.eclipse.sirius.components.view.diagram.NodePalette; | ||
import org.eclipse.sirius.components.view.diagram.SynchronizationPolicy; | ||
|
||
/** | ||
* Used to create the powerInput node description. | ||
* | ||
* @author frouene | ||
*/ | ||
public class PowerInputDescriptionProvider implements INodeDescriptionProvider { | ||
|
||
public static final String NAME = "PowerInput Node"; | ||
|
||
private final IColorProvider colorProvider; | ||
|
||
private final DiagramBuilders diagramBuilderHelper = new DiagramBuilders(); | ||
|
||
private final FlowViewBuilder flowViewBuilder = new FlowViewBuilder(); | ||
|
||
public PowerInputDescriptionProvider(IColorProvider colorProvider) { | ||
this.colorProvider = Objects.requireNonNull(colorProvider); | ||
} | ||
|
||
|
||
@Override | ||
public NodeDescription create() { | ||
|
||
return this.diagramBuilderHelper.newNodeDescription() | ||
.name(NAME) | ||
.domainType("flow::PowerInput") | ||
.semanticCandidatesExpression("feature:powerInputs") | ||
.childrenLayoutStrategy(DiagramFactory.eINSTANCE.createFreeFormLayoutStrategyDescription()) | ||
.defaultHeightExpression("50") | ||
.defaultWidthExpression("50") | ||
.userResizable(false) | ||
.keepAspectRatio(true) | ||
.style(this.flowViewBuilder.createImageNodeStyleDescription(POWER_INPUT_SVG_ID, this.colorProvider)) | ||
.synchronizationPolicy(SynchronizationPolicy.SYNCHRONIZED) | ||
.palette(this.createNodePalette()) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public void link(DiagramDescription diagramDescription, IViewDiagramElementFinder cache) { | ||
cache.getNodeDescription(NAME).ifPresent(nodeDescription -> diagramDescription.getNodeDescriptions().add(nodeDescription)); | ||
} | ||
|
||
private NodePalette createNodePalette() { | ||
|
||
return this.diagramBuilderHelper.newNodePalette() | ||
.deleteTool(this.flowViewBuilder.createDeleteTool()) | ||
.build(); | ||
} | ||
|
||
} |
80 changes: 80 additions & 0 deletions
80
...ipse/sirius/components/flow/starter/view/descriptions/PowerOutputDescriptionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/******************************************************************************* | ||
* 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 | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.flow.starter.view.descriptions; | ||
|
||
import static org.eclipse.sirius.components.flow.starter.view.FlowViewBuilder.POWER_OUTPUT_SVG_ID; | ||
|
||
import java.util.Objects; | ||
|
||
import org.eclipse.sirius.components.flow.starter.view.FlowViewBuilder; | ||
import org.eclipse.sirius.components.view.builder.IViewDiagramElementFinder; | ||
import org.eclipse.sirius.components.view.builder.generated.DiagramBuilders; | ||
import org.eclipse.sirius.components.view.builder.providers.IColorProvider; | ||
import org.eclipse.sirius.components.view.builder.providers.INodeDescriptionProvider; | ||
import org.eclipse.sirius.components.view.diagram.DiagramDescription; | ||
import org.eclipse.sirius.components.view.diagram.DiagramFactory; | ||
import org.eclipse.sirius.components.view.diagram.NodeDescription; | ||
import org.eclipse.sirius.components.view.diagram.NodePalette; | ||
import org.eclipse.sirius.components.view.diagram.SynchronizationPolicy; | ||
|
||
/** | ||
* Used to create the powerOutput node description. | ||
* | ||
* @author frouene | ||
*/ | ||
public class PowerOutputDescriptionProvider implements INodeDescriptionProvider { | ||
|
||
public static final String NAME = "PowerOutput Node"; | ||
|
||
private final IColorProvider colorProvider; | ||
|
||
private final DiagramBuilders diagramBuilderHelper = new DiagramBuilders(); | ||
|
||
private final FlowViewBuilder flowViewBuilder = new FlowViewBuilder(); | ||
|
||
public PowerOutputDescriptionProvider(IColorProvider colorProvider) { | ||
this.colorProvider = Objects.requireNonNull(colorProvider); | ||
} | ||
|
||
|
||
@Override | ||
public NodeDescription create() { | ||
|
||
return this.diagramBuilderHelper.newNodeDescription() | ||
.name(NAME) | ||
.domainType("flow::PowerOutput") | ||
.semanticCandidatesExpression("feature:powerOutputs") | ||
.childrenLayoutStrategy(DiagramFactory.eINSTANCE.createFreeFormLayoutStrategyDescription()) | ||
.defaultHeightExpression("50") | ||
.defaultWidthExpression("50") | ||
.userResizable(false) | ||
.keepAspectRatio(true) | ||
.style(this.flowViewBuilder.createImageNodeStyleDescription(POWER_OUTPUT_SVG_ID, this.colorProvider)) | ||
.synchronizationPolicy(SynchronizationPolicy.SYNCHRONIZED) | ||
.palette(this.createNodePalette()) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public void link(DiagramDescription diagramDescription, IViewDiagramElementFinder cache) { | ||
cache.getNodeDescription(NAME).ifPresent(nodeDescription -> diagramDescription.getNodeDescriptions().add(nodeDescription)); | ||
} | ||
|
||
private NodePalette createNodePalette() { | ||
|
||
return this.diagramBuilderHelper.newNodePalette() | ||
.deleteTool(this.flowViewBuilder.createDeleteTool()) | ||
.build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
.../sirius-components-flow-starter/src/main/resources/customImages/power_input.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions
7
...sirius-components-flow-starter/src/main/resources/customImages/power_output.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.