Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#150 #141 Rework dependency injection architecture #127

Merged
merged 3 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/org.eclipse.glsp.example.workflow/.project
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019 EclipseSource and others.
* Copyright (c) 2019-2021 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 @@ -40,15 +40,12 @@
import org.eclipse.glsp.example.workflow.wfgraph.WfgraphPackage;
import org.eclipse.glsp.graph.DefaultTypes;
import org.eclipse.glsp.graph.GraphPackage;
import org.eclipse.glsp.server.diagram.DiagramConfiguration;
import org.eclipse.glsp.server.diagram.EdgeTypeHint;
import org.eclipse.glsp.server.diagram.ShapeTypeHint;
import org.eclipse.glsp.server.diagram.BaseDiagramConfiguration;
import org.eclipse.glsp.server.layout.ServerLayoutKind;
import org.eclipse.glsp.server.types.EdgeTypeHint;
import org.eclipse.glsp.server.types.ShapeTypeHint;

public class WorkflowDiagramConfiguration implements DiagramConfiguration {

@Override
public String getDiagramType() { return "workflow-diagram"; }
public class WorkflowDiagramConfiguration extends BaseDiagramConfiguration {

@Override
public Map<String, EClass> getTypeMappings() {
Expand Down Expand Up @@ -80,7 +77,7 @@ public List<ShapeTypeHint> getShapeTypeHints() {
public List<EdgeTypeHint> getEdgeTypeHints() {
List<EdgeTypeHint> edgeHints = new ArrayList<>();
edgeHints.add(createDefaultEdgeTypeHint(EDGE));
EdgeTypeHint weightedEdgeHint = DiagramConfiguration.super.createDefaultEdgeTypeHint(WEIGHTED_EDGE);
EdgeTypeHint weightedEdgeHint = super.createDefaultEdgeTypeHint(WEIGHTED_EDGE);
weightedEdgeHint.setSourceElementTypeIds(Arrays.asList(DECISION_NODE));
weightedEdgeHint.setTargetElementTypeIds(Arrays.asList(MANUAL_TASK, AUTOMATED_TASK, FORK_NODE, JOIN_NODE));
edgeHints.add(weightedEdgeHint);
Expand All @@ -89,7 +86,7 @@ public List<EdgeTypeHint> getEdgeTypeHints() {

@Override
public EdgeTypeHint createDefaultEdgeTypeHint(final String elementId) {
EdgeTypeHint hint = DiagramConfiguration.super.createDefaultEdgeTypeHint(elementId);
EdgeTypeHint hint = super.createDefaultEdgeTypeHint(elementId);
hint.setSourceElementTypeIds(
Arrays.asList(MANUAL_TASK, AUTOMATED_TASK, DECISION_NODE, MERGE_NODE, FORK_NODE, JOIN_NODE));
hint.setTargetElementTypeIds(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019-2020 EclipseSource and others.
* Copyright (c) 2019-2021 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 @@ -40,13 +40,13 @@
import org.eclipse.glsp.example.workflow.taskedit.TaskEditValidator;
import org.eclipse.glsp.graph.GraphExtension;
import org.eclipse.glsp.server.actions.ActionHandler;
import org.eclipse.glsp.server.di.DefaultGLSPModule;
import org.eclipse.glsp.server.di.GModelJsonDiagramModule;
import org.eclipse.glsp.server.di.MultiBinding;
import org.eclipse.glsp.server.diagram.DiagramConfiguration;
import org.eclipse.glsp.server.features.commandpalette.CommandPaletteActionProvider;
import org.eclipse.glsp.server.features.contextactions.ContextActionsProvider;
import org.eclipse.glsp.server.features.contextactions.RequestContextActionsHandler;
import org.eclipse.glsp.server.features.contextmenu.ContextMenuItemProvider;
import org.eclipse.glsp.server.features.core.model.GModelFactory;
import org.eclipse.glsp.server.features.core.model.JsonFileGModelLoader;
import org.eclipse.glsp.server.features.core.model.ModelSourceLoader;
import org.eclipse.glsp.server.features.directediting.ContextEditValidator;
Expand All @@ -57,28 +57,21 @@
import org.eclipse.glsp.server.features.navigation.NavigationTargetResolver;
import org.eclipse.glsp.server.features.popup.PopupModelFactory;
import org.eclipse.glsp.server.features.validation.ModelValidator;
import org.eclipse.glsp.server.layout.ILayoutEngine;
import org.eclipse.glsp.server.layout.LayoutEngine;
import org.eclipse.glsp.server.operations.OperationHandler;
import org.eclipse.glsp.server.protocol.GLSPServer;
import org.eclipse.glsp.server.utils.MultiBinding;

public class WorkflowGLSPModule extends DefaultGLSPModule {
public class WorkflowDiagramModule extends GModelJsonDiagramModule {

@Override
protected Class<? extends GLSPServer> bindGLSPServer() {
return WorkflowGLSPServer.class;
protected Class<? extends DiagramConfiguration> bindDiagramConfiguration() {
return WorkflowDiagramConfiguration.class;
}

@Override
protected Class<? extends ModelSourceLoader> bindSourceModelLoader() {
return JsonFileGModelLoader.class;
}

@Override
protected Class<? extends GModelFactory> bindGModelFactory() {
return GModelFactory.NullImpl.class;
}

@Override
protected Class<? extends ModelSourceWatcher> bindModelSourceWatcher() {
return FileWatcher.class;
Expand All @@ -101,11 +94,6 @@ protected void configureContextEditValidators(final MultiBinding<ContextEditVali
binding.add(TaskEditValidator.class);
}

@Override
protected void configureDiagramConfigurations(final MultiBinding<DiagramConfiguration> binding) {
binding.add(WorkflowDiagramConfiguration.class);
}

@Override
protected void configureNavigationTargetProviders(final MultiBinding<NavigationTargetProvider> binding) {
super.configureNavigationTargetProviders(binding);
Expand Down Expand Up @@ -152,7 +140,7 @@ protected Class<? extends LabelEditValidator> bindLabelEditValidator() {
}

@Override
protected Class<? extends ILayoutEngine> bindLayoutEngine() {
protected Class<? extends LayoutEngine> bindLayoutEngine() {
return WorkflowLayoutEngine.class;
}

Expand All @@ -171,4 +159,7 @@ protected Class<? extends NavigationTargetResolver> bindNavigationTargetResolver
return WorkflowNavigationTargetResolver.class;
}

@Override
public String getDiagramType() { return "workflow-diagram"; }

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
********************************************************************************/
package org.eclipse.glsp.example.workflow;

import static org.eclipse.glsp.server.protocol.GLSPServerException.getOrThrow;
import static org.eclipse.glsp.server.types.GLSPServerException.getOrThrow;

import java.util.Map;
import java.util.concurrent.CompletableFuture;

import org.apache.log4j.Logger;
import org.eclipse.glsp.server.jsonrpc.DefaultGLSPServer;
import org.eclipse.glsp.server.protocol.DefaultGLSPServer;
import org.eclipse.glsp.server.protocol.InitializeResult;
import org.eclipse.glsp.server.utils.MapUtil;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019 EclipseSource and others.
* Copyright (c) 2019-2021 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,9 +19,10 @@

import org.apache.commons.cli.ParseException;
import org.eclipse.elk.alg.layered.options.LayeredMetaDataProvider;
import org.eclipse.glsp.example.workflow.WorkflowGLSPModule;
import org.eclipse.glsp.example.workflow.WorkflowDiagramModule;
import org.eclipse.glsp.layout.ElkLayoutEngine;
import org.eclipse.glsp.server.launch.DefaultGLSPServerLauncher;
import org.eclipse.glsp.server.di.ServerModule;
import org.eclipse.glsp.server.launch.SocketGLSPServerLauncher;
import org.eclipse.glsp.server.launch.GLSPServerLauncher;
import org.eclipse.glsp.server.utils.LaunchUtil;
import org.eclipse.glsp.server.websocket.WebsocketServerLauncher;
Expand All @@ -38,10 +39,12 @@ public static void main(final String[] args) {
ElkLayoutEngine.initialize(new LayeredMetaDataProvider());

int port = parser.parsePort();
ServerModule workflowServerModule = new ServerModule()
.configureDiagramModule(new WorkflowDiagramModule());

GLSPServerLauncher launcher = parser.isWebsocket()
? new WebsocketServerLauncher(new WorkflowGLSPModule(), "/workflow")
: new DefaultGLSPServerLauncher(new WorkflowGLSPModule());
? new WebsocketServerLauncher(workflowServerModule, "/workflow")
: new SocketGLSPServerLauncher(workflowServerModule);

launcher.start("localhost", port);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
import org.eclipse.glsp.server.features.navigation.NavigationTargetProvider;
import org.eclipse.glsp.server.model.GModelState;
import org.eclipse.glsp.server.types.EditorContext;
import org.eclipse.glsp.server.utils.ClientOptions;
import org.eclipse.glsp.server.utils.ClientOptionsUtil;
import org.eclipse.glsp.server.utils.MapUtil;

public abstract class AbstractNextOrPreviousNavigationTargetProvider implements NavigationTargetProvider {

@Override
public List<? extends NavigationTarget> getTargets(final EditorContext editorContext,
final GModelState modelState) {
Optional<String> sourceUri = MapUtil.getValue(modelState.getClientOptions(), ClientOptions.SOURCE_URI);
Optional<String> sourceUri = MapUtil.getValue(modelState.getClientOptions(), ClientOptionsUtil.SOURCE_URI);
return editorContext.getSelectedElementIds().stream()
.flatMap(id -> modelState.getIndex().get(id).stream())
.filter(TaskNode.class::isInstance).map(TaskNode.class::cast)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.eclipse.glsp.server.features.navigation.NavigationTargetProvider;
import org.eclipse.glsp.server.model.GModelState;
import org.eclipse.glsp.server.types.EditorContext;
import org.eclipse.glsp.server.utils.ClientOptions;
import org.eclipse.glsp.server.utils.ClientOptionsUtil;
import org.eclipse.glsp.server.utils.MapUtil;

/**
Expand All @@ -50,7 +50,7 @@ public List<? extends NavigationTarget> getTargets(final EditorContext editorCon
return Arrays.asList();
}

Optional<String> sourceUri = MapUtil.getValue(modelState.getClientOptions(), ClientOptions.SOURCE_URI);
Optional<String> sourceUri = MapUtil.getValue(modelState.getClientOptions(), ClientOptionsUtil.SOURCE_URI);
if (sourceUri.isEmpty()) {
return Arrays.asList();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2020 EclipseSource and others.
* Copyright (c) 2020-2021 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 @@ -18,7 +18,7 @@
import org.eclipse.glsp.server.actions.ActionDispatcher;
import org.eclipse.glsp.server.model.GModelState;
import org.eclipse.glsp.server.operations.BasicOperationHandler;
import org.eclipse.glsp.server.protocol.GLSPServerException;
import org.eclipse.glsp.server.types.GLSPServerException;

import com.google.inject.Inject;

Expand All @@ -32,12 +32,10 @@ protected void executeOperation(final ApplyTaskEditOperation operation, final GM
String text = operation.getExpression();
if (text.startsWith(TaskEditContextActionProvider.DURATION_PREFIX)) {
String durationString = text.substring(TaskEditContextActionProvider.DURATION_PREFIX.length());
actionProcessor.dispatch(modelState.getClientId(),
new EditTaskOperation(operation.getTaskId(), "duration", durationString));
actionProcessor.dispatch(new EditTaskOperation(operation.getTaskId(), "duration", durationString));
} else if (text.startsWith(TaskEditContextActionProvider.TYPE_PREFIX)) {
String typeString = text.substring(TaskEditContextActionProvider.TYPE_PREFIX.length());
actionProcessor.dispatch(modelState.getClientId(),
new EditTaskOperation(operation.getTaskId(), "taskType", typeString));
actionProcessor.dispatch(new EditTaskOperation(operation.getTaskId(), "taskType", typeString));
} else {
throw new GLSPServerException(
"Cannot process 'ApplyTaskEditOperation' expression: " + operation.getExpression());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2020 EclipseSource and others.
* Copyright (c) 2020-2021 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 @@ -20,7 +20,7 @@
import org.eclipse.glsp.example.workflow.wfgraph.TaskNode;
import org.eclipse.glsp.server.model.GModelState;
import org.eclipse.glsp.server.operations.BasicOperationHandler;
import org.eclipse.glsp.server.protocol.GLSPServerException;
import org.eclipse.glsp.server.types.GLSPServerException;

public class EditTaskOperationHandler extends BasicOperationHandler<EditTaskOperation> {

Expand Down
4 changes: 2 additions & 2 deletions plugins/org.eclipse.glsp.graph/.project
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=11
org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled
org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,HIGH,LOW,LOW,LOW,LOW,LOW,NORMAL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2019 EclipseSource and others.
* Copyright (c) 2019-2021 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 @@ -40,18 +40,18 @@

import com.google.gson.GsonBuilder;

public class GGraphGsonConfigurator {
public class GraphGsonConfigurator {

public static final String DEFAULT_TYPE_ATT = "type";

private final Map<String, EClass> typeMap = new HashMap<>();
private final List<EPackage> ePackages = new ArrayList<>();

public GGraphGsonConfigurator() {
public GraphGsonConfigurator() {
withEPackages(GraphPackage.eINSTANCE);
}

public GGraphGsonConfigurator withDefaultTypes() {
public GraphGsonConfigurator withDefaultTypes() {
Map<String, EClass> defaultTypes = new HashMap<>();
defaultTypes.put(GRAPH, GGRAPH);
defaultTypes.put(NODE, GNODE);
Expand All @@ -61,12 +61,12 @@ public GGraphGsonConfigurator withDefaultTypes() {
return withTypes(defaultTypes);
}

public GGraphGsonConfigurator withTypes(final Map<String, EClass> types) {
public GraphGsonConfigurator withTypes(final Map<String, EClass> types) {
typeMap.putAll(types);
return this;
}

public GGraphGsonConfigurator withEPackages(final EPackage... packages) {
public GraphGsonConfigurator withEPackages(final EPackage... packages) {
ePackages.addAll(Arrays.asList(packages));
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=11
org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled
org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,HIGH,LOW,LOW,LOW,LOW,LOW,NORMAL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/********************************************************************************
* Copyright (c) 2018 TypeFox and others.
* (c) 2019 EclipseSource (adaptation for GModel)
* (c) 2019-2021 EclipseSource (adaptation for GModel)
*
* 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 @@ -59,7 +59,7 @@
import org.eclipse.glsp.graph.GPoint;
import org.eclipse.glsp.graph.GPort;
import org.eclipse.glsp.graph.GraphFactory;
import org.eclipse.glsp.server.layout.ILayoutEngine;
import org.eclipse.glsp.server.layout.LayoutEngine;
import org.eclipse.glsp.server.model.GModelState;

import com.google.common.collect.Maps;
Expand All @@ -75,7 +75,7 @@
* algorithms that should be used by this layout engine.
* </p>
*/
public class ElkLayoutEngine implements ILayoutEngine {
public class ElkLayoutEngine implements LayoutEngine {

public static final IProperty<String> P_TYPE = new Property<>("org.eclipse.sprotty.layout.type");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=11
org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled
org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,HIGH,LOW,LOW,LOW,LOW,LOW,NORMAL
Expand Down
Loading