Replies: 1 comment 1 reply
-
Hi @mrcalvin, It might be hard to find the cultprit by just relying on logs. I would recommend to debug into the To do this you can start the server manually (in debug mode) in an IDE of your choice (Launch configurations for VS Code and Eclipse are already part of the project template). Then you have to start the Theia application in yarn start:external or with the
Command execution (and node creation) should still work with your approach. However, the For now this is ok. But once you have fixed/found the cultprint and node creation is working as expected you probably have to adapt this and use OperationHandlers/Commands that are scoped to your source model. First I would recommend to create abstract base classes for GF-based operation handlers: public abstract class GFOperationHandler<O extends Operation> extends BasicOperationHandler<O> {
// Put common functionality e.g. utility methods or props that will be used in (most of) the subclasses
@Inject()
protected GFModelState modelState;
@Inject()
protected ActionDispatcher actionDispatcher;
} public abstract class GFCreateOperationHandler<T extends CreateOperation>
extends GFOperationHandler<T> implements CreateOperationHandler<T> {
protected List<String> handledElementTypeIds;
public GFCreateOperationHandler(final String... elementTypeIds) {
this(Lists.newArrayList(elementTypeIds));
}
public GFCreateOperationHandler(final List<String> handledElementTypeIds) {
this.handledElementTypeIds = handledElementTypeIds;
}
@Override
public List<String> getHandledElementTypeIds() { return handledElementTypeIds; }
public void setHandledElementTypeIds(final List<String> handledElementTypeIds) {
this.handledElementTypeIds = handledElementTypeIds;
}
// Additional common utilities for create handlers
} Then you can derive the ...
import org.eclipse.emf.common.command.AbstractCommand;
public class CreateFeatureNodeHandler extends GFCreateOperationHandler<CreateNodeOperation> {
public CreateFeatureNodeHandler() {
super(TaskListModelTypes.FEATURE);
}
@Override
public Optional<Command> createCommand(final CreateNodeOperation operation) {
return new CreateFeatureCommand(this.modelState.getFModel());
}
class CreateFeatureCommand extends AbstractCommand {
private final IFeatureModel model;
private IFeature addedFeature;
CreateFeatureCommand(final IFeatureModel model) {
this.model = model;
}
@Override
public void execute() {
final IFeatureModelFactory factory = DefaultFeatureModelFactory.getInstance();
final String name = "new_one" + String.valueOf(model.getNumberOfFeatures());
final IFeature feature = factory.createFeature(model, name);
model.addFeature(feature);
this.addedFeature = feature;
LOGGER.info("created 2: " + feature.getName());
}
@Override
public void redo() {
if (this.addedFeature != null) {
model.addFeature(feature)
}
}
@Override
public void undo() {
if (this.addedFeature != null) {
model.removeFeature(addedFeature)
}
}
}
} (Command implementation is just a rough sketch and probably needs some adaption to work properly) |
Beta Was this translation helpful? Give feedback.
-
Hi everyone!
First, let me say that I am impressed by GLSP and your team/ community efforts around it. I enjoy programming in and with it (despite my Java being rusty, my TypeScript basically being non-existent, and my epic personal battle with Maven).
I started working on modifying the java-emf-theia, threw out the EMF stuff, and started introducing my own (non-EMF) source model etc. Now I experience the following client-side issue:
This happens at different points in time (sometimes sooner, sometimes later) when creating new nodes from the palette. The result is that the current diagram freezes, I need to reopen it and start all over (with the state being gone, unsaved etc.)
Did I break the command execution machinery, by introducing my own
GModelOperationHandler
for theCreateNodeOperation
? (I am flying blind here, as the tutorial here is still in GLSP < 2 state, as the disclaimer states).How can I find the culprit?
Full log.txt
Beta Was this translation helpful? Give feedback.
All reactions