-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1397] Add support for reused node descriptions
Bug: #1397 Signed-off-by: Stéphane Bégaudeau <[email protected]>
- Loading branch information
1 parent
8ee526e
commit 2c6eb1a
Showing
22 changed files
with
382 additions
and
35 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
27 changes: 27 additions & 0 deletions
27
...ain/java/org/eclipse/sirius/components/diagrams/components/INodeDescriptionRequestor.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,27 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 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.diagrams.components; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
import org.eclipse.sirius.components.diagrams.description.NodeDescription; | ||
|
||
/** | ||
* Used to find some node descriptions. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
public interface INodeDescriptionRequestor { | ||
Optional<NodeDescription> findById(UUID nodeDescriptionId); | ||
} |
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
47 changes: 47 additions & 0 deletions
47
...main/java/org/eclipse/sirius/components/diagrams/components/NodeDescriptionRequestor.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,47 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 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.diagrams.components; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
import org.eclipse.sirius.components.diagrams.description.DiagramDescription; | ||
import org.eclipse.sirius.components.diagrams.description.NodeDescription; | ||
|
||
/** | ||
* Find the requested node descriptions. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
public class NodeDescriptionRequestor implements INodeDescriptionRequestor { | ||
|
||
private final Map<UUID, NodeDescription> id2nodeDescription = new HashMap<>(); | ||
|
||
public NodeDescriptionRequestor(DiagramDescription diagramDescription) { | ||
diagramDescription.getNodeDescriptions().forEach(this::cache); | ||
} | ||
|
||
private void cache(NodeDescription nodeDescription) { | ||
this.id2nodeDescription.put(nodeDescription.getId(), nodeDescription); | ||
nodeDescription.getBorderNodeDescriptions().forEach(this::cache); | ||
nodeDescription.getChildNodeDescriptions().forEach(this::cache); | ||
} | ||
|
||
@Override | ||
public Optional<NodeDescription> findById(UUID nodeDescriptionId) { | ||
return Optional.ofNullable(this.id2nodeDescription.get(nodeDescriptionId)); | ||
} | ||
|
||
} |
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
Oops, something went wrong.