Skip to content

Commit 136a0d7

Browse files
authored
Merge pull request #14 from /issues/12-13
#12 #13 Provide LayoutCommandContribution and separate notation commands plugin
2 parents 77fe0f5 + 1aebd18 commit 136a0d7

33 files changed

Lines changed: 1069 additions & 68 deletions

File tree

plugins/org.eclipse.emfcloud.modelserver.glsp.integration/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ Require-Bundle: org.eclipse.glsp.server,
1717
org.eclipse.elk.core;bundle-version="0.7.0",
1818
org.eclipse.elk.graph;bundle-version="0.7.0",
1919
org.eclipse.elk.alg.layered;bundle-version="0.7.0",
20+
org.eclipse.emf.ecore,
2021
org.eclipse.emfcloud.modelserver.glsp.notation.model,
21-
org.eclipse.emf.ecore
22+
org.eclipse.emfcloud.modelserver.glsp.notation.commands
2223
Bundle-ClassPath: .
2324
Export-Package: org.eclipse.emfcloud.modelserver.glsp,
2425
org.eclipse.emfcloud.modelserver.glsp.actions.handlers,

plugins/org.eclipse.emfcloud.modelserver.glsp.integration/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@
5959
<dependency>
6060
<groupId>org.eclipse.emfcloud.modelserver.glsp</groupId>
6161
<artifactId>org.eclipse.emfcloud.modelserver.glsp.notation.model</artifactId>
62-
<version>${modelserver.version}</version>
62+
<version>${project.version}</version>
63+
</dependency>
64+
<dependency>
65+
<groupId>org.eclipse.emfcloud.modelserver.glsp</groupId>
66+
<artifactId>org.eclipse.emfcloud.modelserver.glsp.notation.commands</artifactId>
67+
<version>${project.version}</version>
6368
</dependency>
6469
<dependency>
6570
<groupId>org.eclipse.glsp</groupId>

plugins/org.eclipse.emfcloud.modelserver.glsp.integration/src/org/eclipse/emfcloud/modelserver/glsp/model/EMSModelSourceLoader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ public abstract class EMSModelSourceLoader implements ModelSourceLoader {
3535
public static final String WORKSPACE_ROOT_OPTION = "workspaceRoot";
3636

3737
@Inject
38-
private ModelServerClientProvider modelServerClientProvider;
38+
protected ModelServerClientProvider modelServerClientProvider;
3939

4040
@Inject
41-
private ActionDispatcher actionDispatcher;
41+
protected ActionDispatcher actionDispatcher;
4242

4343
@Inject
4444
protected ModelSubmissionHandler submissionHandler;

plugins/org.eclipse.emfcloud.modelserver.glsp.integration/src/org/eclipse/emfcloud/modelserver/glsp/notation/integration/EMSNotationModelServerAccess.java

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
********************************************************************************/
1111
package org.eclipse.emfcloud.modelserver.glsp.notation.integration;
1212

13+
import java.util.HashMap;
14+
import java.util.List;
1315
import java.util.Map;
1416
import java.util.concurrent.CompletableFuture;
1517
import java.util.concurrent.ExecutionException;
@@ -22,14 +24,19 @@
2224
import org.eclipse.emfcloud.modelserver.command.CCommandFactory;
2325
import org.eclipse.emfcloud.modelserver.command.CCompoundCommand;
2426
import org.eclipse.emfcloud.modelserver.glsp.EMSModelServerAccess;
27+
import org.eclipse.emfcloud.modelserver.glsp.notation.Edge;
2528
import org.eclipse.emfcloud.modelserver.glsp.notation.Shape;
2629
import org.eclipse.emfcloud.modelserver.glsp.notation.commands.contribution.ChangeBoundsCommandContribution;
30+
import org.eclipse.emfcloud.modelserver.glsp.notation.commands.contribution.ChangeRoutingPointsCommandContribution;
31+
import org.eclipse.emfcloud.modelserver.glsp.notation.commands.contribution.LayoutCommandContribution;
2732
import org.eclipse.glsp.graph.GDimension;
33+
import org.eclipse.glsp.graph.GEdge;
2834
import org.eclipse.glsp.graph.GModelElement;
2935
import org.eclipse.glsp.graph.GNode;
3036
import org.eclipse.glsp.graph.GPoint;
3137
import org.eclipse.glsp.server.protocol.GLSPServerException;
3238
import org.eclipse.glsp.server.types.ElementAndBounds;
39+
import org.eclipse.glsp.server.types.ElementAndRoutingPoints;
3340

3441
public abstract class EMSNotationModelServerAccess extends EMSModelServerAccess {
3542

@@ -80,30 +87,45 @@ public CompletableFuture<Response<Boolean>> changeSize(final Shape shape, final
8087
}
8188

8289
/*
83-
* Auto layouting
90+
* Change Routing Points
8491
*/
85-
protected CCompoundCommand createLayoutCommand(final EMSNotationModelState modelState,
86-
final GModelElement layoutedRoot) {
92+
public CompletableFuture<Response<Boolean>> changeRoutingPoints(
93+
final Map<Edge, ElementAndRoutingPoints> changeBendPointsMap) {
8794
CCompoundCommand compoundCommand = CCommandFactory.eINSTANCE.createCompoundCommand();
88-
compoundCommand.setType(ChangeBoundsCommandContribution.TYPE);
89-
90-
layoutedRoot.getChildren().forEach(gModelElement -> {
91-
if (gModelElement instanceof GNode) {
92-
modelState.getIndex().getNotation(gModelElement.getId(), Shape.class).ifPresent(shape -> {
93-
CCommand changeBoundsCommand = ChangeBoundsCommandContribution.create(
94-
shape.getSemanticElement().getUri(), ((GNode) gModelElement).getPosition(),
95-
((GNode) gModelElement).getSize());
96-
compoundCommand.getCommands().add(changeBoundsCommand);
97-
});
98-
}
99-
});
95+
compoundCommand.setType(ChangeRoutingPointsCommandContribution.TYPE);
10096

101-
return compoundCommand;
97+
changeBendPointsMap.forEach((edge, elementAndRoutingPoints) -> {
98+
CCommand changeRoutingPointsCommand = ChangeRoutingPointsCommandContribution
99+
.create(edge.getSemanticElement().getUri(), elementAndRoutingPoints.getNewRoutingPoints());
100+
compoundCommand.getCommands().add(changeRoutingPointsCommand);
101+
});
102+
return this.edit(compoundCommand);
102103
}
103104

105+
/*
106+
* Auto layouting
107+
*/
104108
public CompletableFuture<Response<Boolean>> setLayout(final EMSNotationModelState modelState,
105109
final GModelElement layoutedRoot) {
106-
CCompoundCommand compoundCommand = createLayoutCommand(modelState, layoutedRoot);
110+
Map<Shape, ElementAndBounds> changeBoundsMap = new HashMap<>();
111+
Map<Edge, List<GPoint>> changeBendPointsMap = new HashMap<>();
112+
113+
layoutedRoot.getChildren().forEach(layoutedGModelElement -> {
114+
if (layoutedGModelElement instanceof GNode) {
115+
modelState.getIndex().getNotation(layoutedGModelElement.getId(), Shape.class).ifPresent(shape -> {
116+
ElementAndBounds eb = new ElementAndBounds();
117+
eb.setNewPosition(((GNode) layoutedGModelElement).getPosition());
118+
eb.setNewSize(((GNode) layoutedGModelElement).getSize());
119+
changeBoundsMap.put(shape, eb);
120+
});
121+
} else if (layoutedGModelElement instanceof GEdge) {
122+
modelState.getIndex().getNotation(layoutedGModelElement.getId(), Edge.class).ifPresent(edge -> {
123+
changeBendPointsMap.put(edge, ((GEdge) layoutedGModelElement).getRoutingPoints());
124+
});
125+
}
126+
});
127+
128+
CCompoundCommand compoundCommand = LayoutCommandContribution.create(changeBoundsMap, changeBendPointsMap);
107129
return this.edit(compoundCommand);
108130
}
109131
}

plugins/org.eclipse.emfcloud.modelserver.glsp.integration/src/org/eclipse/emfcloud/modelserver/glsp/notation/integration/EMSNotationModelServerModule.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
import org.eclipse.emfcloud.modelserver.emf.di.DefaultModelServerModule;
1818
import org.eclipse.emfcloud.modelserver.glsp.notation.commands.contribution.ChangeBoundsCommandContribution;
1919
import org.eclipse.emfcloud.modelserver.glsp.notation.commands.contribution.ChangeRoutingPointsCommandContribution;
20-
import org.eclipse.emfcloud.modelserver.glsp.notation.model.NotationPackageConfiguration;
20+
import org.eclipse.emfcloud.modelserver.glsp.notation.commands.contribution.LayoutCommandContribution;
21+
import org.eclipse.emfcloud.modelserver.glsp.notation.epackage.NotationPackageConfiguration;
2122

2223
public abstract class EMSNotationModelServerModule extends DefaultModelServerModule {
2324

@@ -34,6 +35,8 @@ protected void configureCommandCodecs(final MapBinding<String, CommandContributi
3435
binding.put(ChangeBoundsCommandContribution.TYPE, ChangeBoundsCommandContribution.class);
3536
// ChangeRoutingPoints
3637
binding.put(ChangeRoutingPointsCommandContribution.TYPE, ChangeRoutingPointsCommandContribution.class);
38+
// Layout
39+
binding.put(LayoutCommandContribution.TYPE, LayoutCommandContribution.class);
3740
}
3841

3942
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<fileset-config file-format-version="1.2.0" simple-config="false" sync-formatter="false">
2+
<local-check-config name="EMF.cloud Checkstyle" location="https://raw.githubusercontent.com/eclipse-emfcloud/emfcloud/master/codestyle/org.eclipse.emfcloud.checkstyle/src/main/resources/emfcloud-checkstyle.xml" type="remote" description="The central checkstyle configuration for emfcloud">
3+
<additional-data name="cache-props-file-location" value="EMFcloud Checkstyle_1618908540765_cache.properties"/>
4+
<additional-data name="cache-file" value="true"/>
5+
<additional-data name="cache-file-location" value="EMFcloud Checkstyle_1618908540765_cache.xml"/>
6+
</local-check-config>
7+
<fileset name="all" enabled="true" check-config-name="EMF.cloud Checkstyle" local="true">
8+
<file-match-pattern match-pattern=".java$" include-pattern="true"/>
9+
</fileset>
10+
</fileset-config>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
4+
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5+
<classpathentry kind="src" path="src/"/>
6+
<classpathentry kind="output" path="target/classes"/>
7+
</classpath>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>org.eclipse.emfcloud.modelserver.glsp.notation.commands</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.pde.ManifestBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.pde.SchemaBuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>org.eclipse.m2e.core.maven2Builder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
31+
<nature>org.eclipse.pde.PluginNature</nature>
32+
<nature>org.eclipse.jdt.core.javanature</nature>
33+
</natures>
34+
</projectDescription>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding/<project>=UTF-8

0 commit comments

Comments
 (0)