-
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.
[2883] Store in node layout data if a user has resized the node
Bug: #2883 Signed-off-by: Guillaume Coutable <guillaume.coutable@obeo.fr>
- Loading branch information
Showing
24 changed files
with
145 additions
and
42 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
54 changes: 54 additions & 0 deletions
54
...sirius/components/diagrams/graphql/datafetchers/diagram/NodeResizedByUserDataFetcher.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,54 @@ | ||
/******************************************************************************* | ||
* 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.diagrams.graphql.datafetchers.diagram; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import org.eclipse.sirius.components.annotations.spring.graphql.QueryDataFetcher; | ||
import org.eclipse.sirius.components.diagrams.Diagram; | ||
import org.eclipse.sirius.components.diagrams.Node; | ||
import org.eclipse.sirius.components.diagrams.layoutdata.DiagramLayoutData; | ||
import org.eclipse.sirius.components.diagrams.layoutdata.NodeLayoutData; | ||
import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates; | ||
|
||
import graphql.schema.DataFetchingEnvironment; | ||
|
||
/** | ||
* Used to retrieve the resized by user from diagram layout data. | ||
* | ||
* @author gcoutable | ||
*/ | ||
@QueryDataFetcher(type = "Node", field = "resizedByUser") | ||
public class NodeResizedByUserDataFetcher implements IDataFetcherWithFieldCoordinates<Boolean> { | ||
|
||
@Override | ||
public Boolean get(DataFetchingEnvironment environment) throws Exception { | ||
Node node = environment.getSource(); | ||
Map<String, Object> localContext = environment.getLocalContext(); | ||
|
||
return Optional.ofNullable(localContext.get("diagram")) | ||
.filter(Diagram.class::isInstance) | ||
.map(Diagram.class::cast) | ||
.flatMap(diagram -> this.resizedByUser(diagram, node)) | ||
.orElse(false); | ||
} | ||
|
||
private Optional<Boolean> resizedByUser(Diagram diagram, Node node) { | ||
return Optional.of(diagram.getLayoutData()) | ||
.map(DiagramLayoutData::nodeLayoutData) | ||
.map(layoutData -> layoutData.get(node.getId())) | ||
.map(NodeLayoutData::resizedByUser); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,5 +69,6 @@ fragment nodeFragment on Node { | |
defaultWidth | ||
defaultHeight | ||
labelEditable | ||
resizedByUser | ||
} | ||
`; |
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
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.