Skip to content

Commit

Permalink
#47 #48 Update to latest GLSP version due to API breaks and fix unsub…
Browse files Browse the repository at this point in the history
…scribing (#49)

* #48 Fix unsubscription on closing/reloading application

Until now unsubscribe was only triggered if a diagram editor was closed but not on application close/refresh.

Fixes #48

* #47 Update to latest GLSP version due to API breaks

- Refactoring of OperationHandler type hierarchy API, see also eclipse-glsp/glsp-server#187
  - Stay with executeOperation method as we manage command stack via Model Server
  - Merge interfaces and abstract operation handler classes
- Update GLSP and Model Server dependencies

Part of #47

* #43 Follow-up: Update maven settings and Jenkinsbuild

- Remove maven config and only use custom maven settings if necessary (i.e. Jenkinsbuild)
- Remove maven config and settings from project template
- Update Jenkinsbuild (do not build project-template with base framework as we have a separate build job for this)
  • Loading branch information
ndoschek authored Feb 15, 2023
1 parent 91d4c93 commit 4e48d4b
Show file tree
Hide file tree
Showing 23 changed files with 109 additions and 201 deletions.
1 change: 0 additions & 1 deletion .mvn/maven.config

This file was deleted.

30 changes: 2 additions & 28 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pipeline {
steps {
timeout(30) {
container("ci") {
sh "mvn clean verify -Pp2 -B -Dmaven.repo.local=${MAVEN_LOCAL_REPO}"
sh "mvn clean verify -Pp2 -B -Dmaven.repo.local=${MAVEN_LOCAL_REPO} --settings ./.mvn/custom-settings.xml"
}
}
}
Expand All @@ -61,38 +61,12 @@ pipeline {
steps {
timeout(30) {
container("ci") {
sh "mvn clean verify -Pm2 -B -Dmaven.repo.local=${MAVEN_LOCAL_REPO}"
sh "mvn clean verify -Pm2 -B -Dmaven.repo.local=${MAVEN_LOCAL_REPO} --settings ./.mvn/custom-settings.xml"
}
}
}
}

stage ("Build: modelserver-glsp-integration example - server") {
steps {
timeout(30) {
container("ci") {
// Do not use dir(..) as it causes problems with mvn
sh "cd project-templates/modelserver-glspjava-emf-theia/server"
sh "mvn clean verify -B -Dmaven.repo.local=${MAVEN_LOCAL_REPO}"
}
}
}
}

stage ("Build: modelserver-glsp-integration example - client") {
steps {
timeout(30){
container("ci") {
dir("project-templates/modelserver-glspjava-emf-theia") {
withCredentials([string(credentialsId: "github-bot-token", variable: "GITHUB_TOKEN")]) {
sh "yarn build:client"
}
}
}
}
}
}

stage("Deploy (main only)") {
when { branch "main" }
steps {
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ The following libraries/frameworks need to be installed on your system:
| [Java](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html) | `>= 11` | We support the two latest LTS versions (11 and 17) |
| [Maven](https://maven.apache.org/) | `>=3.6.0` | |

## Project Template

This repository includes a project-template that combines Model Server, Java GLSP-Server, EMF model inside a Theia application.
See its [README](./project-templates/modelserver-glspjava-emf-theia/README.md) for further details.

> **Remark:** This project-template relies on the latest published versions of Model Server, GLSP and the Model Server GLSP integration. This means, it is built separately from the integration framework.
## Where to find the sources?

In addition to this repository, the related source code can be found here:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2021-2022 EclipseSource and others.
* Copyright (c) 2021-2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -120,7 +120,7 @@ protected void configureActionHandlers(final MultiBinding<ActionHandler> binding
}

@Override
protected void configureOperationHandlers(final MultiBinding<OperationHandler> bindings) {
protected void configureOperationHandlers(final MultiBinding<OperationHandler<?>> bindings) {
super.configureOperationHandlers(bindings);
bindings.rebind(CompoundOperationHandler.class, EMSCompoundOperationHandler.class);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2021-2022 EclipseSource and others.
* Copyright (c) 2021-2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -14,7 +14,6 @@

import java.net.MalformedURLException;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

Expand All @@ -24,10 +23,7 @@
import org.eclipse.emfcloud.modelserver.client.v2.ModelServerClientV2;
import org.eclipse.emfcloud.modelserver.glsp.client.ModelServerClientProvider;
import org.eclipse.glsp.server.protocol.DefaultGLSPServer;
import org.eclipse.glsp.server.protocol.DisposeClientSessionParameters;
import org.eclipse.glsp.server.protocol.InitializeResult;
import org.eclipse.glsp.server.types.GLSPServerException;
import org.eclipse.glsp.server.utils.ClientOptionsUtil;
import org.eclipse.glsp.server.utils.MapUtil;

import com.google.inject.Inject;
Expand Down Expand Up @@ -74,15 +70,4 @@ protected ModelServerClientV2 createModelServerClient(final String modelServerUR
return new ModelServerClientV2(modelServerURL);
}

@Override
public CompletableFuture<Void> disposeClientSession(final DisposeClientSessionParameters params) {
Optional<ModelServerClientV2> modelServerClient = modelServerClientProvider.get();
if (modelServerClient.isPresent()) {
String sourceURI = ClientOptionsUtil.getSourceUri(params.getArgs())
.orElseThrow(() -> new GLSPServerException("No source URI given to dispose client session!"));
modelServerClient.get().unsubscribe(sourceURI);
}
return super.disposeClientSession(params);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2021-2022 EclipseSource and others.
* Copyright (c) 2021-2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -55,6 +55,7 @@ public void sessionDisposed(final ClientSession clientSession) {
modelServerAccess.close().thenAccept(response -> {
LOGGER.warn("Error on disposing ClientSession: " + response.getMessage());
});
modelServerAccess.unsubscribe();
}
super.sessionDisposed(clientSession);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2021 EclipseSource and others.
* Copyright (c) 2021-2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -25,15 +25,15 @@ public class EMSOperationActionHandler extends OperationActionHandler {
public List<Action> executeAction(final Operation operation) {
// Disable the special handling for CreateOperation, as we don't register
// one handler per element type to create.
Optional<? extends OperationHandler> operationHandler = operationHandlerRegistry.get(operation);
Optional<? extends OperationHandler<?>> operationHandler = operationHandlerRegistry.get(operation);
if (operationHandler.isPresent()) {
return executeHandler(operation, operationHandler.get());
}
return none();
}

@Override
protected List<Action> executeHandler(final Operation operation, final OperationHandler handler) {
protected List<Action> executeHandler(final Operation operation, final OperationHandler<?> handler) {
if (handler instanceof EMSOperationHandler) {
handler.execute(operation);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2021-2022 EclipseSource and others.
* Copyright (c) 2021-2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -74,7 +74,7 @@ protected Class<? extends LayoutEngine> bindLayoutEngine() {
}

@Override
protected void configureOperationHandlers(final MultiBinding<OperationHandler> binding) {
protected void configureOperationHandlers(final MultiBinding<OperationHandler<?>> binding) {
super.configureOperationHandlers(binding);
binding.rebind(LayoutOperationHandler.class, EMSLayoutOperationHandler.class);
binding.add(EMSChangeBoundsOperationHandler.class);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2021-2022 EclipseSource and others.
* Copyright (c) 2021-2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -22,7 +22,7 @@

import com.google.inject.Inject;

public class EMSChangeBoundsOperationHandler extends AbstractEMSOperationHandler<ChangeBoundsOperation> {
public class EMSChangeBoundsOperationHandler extends EMSOperationHandler<ChangeBoundsOperation> {

@Inject
protected EMSNotationModelState modelState;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2022 EclipseSource and others.
* Copyright (c) 2022-2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -22,7 +22,7 @@

import com.google.inject.Inject;

public class EMSChangeRoutingPointsOperationHandler extends AbstractEMSOperationHandler<ChangeRoutingPointsOperation> {
public class EMSChangeRoutingPointsOperationHandler extends EMSOperationHandler<ChangeRoutingPointsOperation> {

@Inject
protected EMSNotationModelState modelState;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2022 EclipseSource and others.
* Copyright (c) 2022-2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -19,7 +19,7 @@

import com.google.inject.Inject;

public class EMSCompoundOperationHandler extends AbstractEMSOperationHandler<CompoundOperation> {
public class EMSCompoundOperationHandler extends EMSOperationHandler<CompoundOperation> {

@Inject
protected OperationHandlerRegistry operationHandlerRegistry;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/********************************************************************************
* Copyright (c) 2021-2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0, or the MIT License which is
* available at https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: EPL-2.0 OR MIT
********************************************************************************/
package org.eclipse.emfcloud.modelserver.glsp.operations.handlers;

import java.util.List;

import org.eclipse.emfcloud.modelserver.glsp.EMSModelServerAccess;
import org.eclipse.emfcloud.modelserver.glsp.EMSModelState;
import org.eclipse.glsp.server.operations.CreateOperation;
import org.eclipse.glsp.server.operations.CreateOperationHandler;

import com.google.common.collect.Lists;
import com.google.inject.Inject;

public abstract class EMSCreateOperationHandler<T extends CreateOperation>
extends EMSOperationHandler<T> implements CreateOperationHandler<T> {

@Inject
protected EMSModelState modelState;
@Inject
protected EMSModelServerAccess modelServerAccess;

protected List<String> handledElementTypeIds;

public EMSCreateOperationHandler(final String... elementTypeIds) {
this(Lists.newArrayList(elementTypeIds));
}

public EMSCreateOperationHandler(final List<String> handledElementTypeIds) {
this.handledElementTypeIds = handledElementTypeIds;
}

@Override
public List<String> getHandledElementTypeIds() { return handledElementTypeIds; }

public void setHandledElementTypeIds(final List<String> handledElementTypeIds) {
this.handledElementTypeIds = handledElementTypeIds;
}

}
Loading

0 comments on commit 4e48d4b

Please sign in to comment.