Sirius – Provide custom model operation

Goals

Sirius provides various model operations (change context, if, for, create instance, etc). This extension point allows the contribution of additional model operations.

Define a model operation extension

This extension point is identified as org.eclipse.sirius.diagram.bundledImageShape. In this extension, there are three required fields:

The model operation manager will have to create a Sirius task from the given description of the model operation. An example is available in the plugin org.eclipse.sirius.ui.properties with the class org.eclipse.sirius.ui.properties.internal.dialog.DialogModelOperationManager.

public class DialogModelOperationManager implements IModelOperationManager {

    @Override
    public Optional<ICommandTask> createTask(ModelOperation modelOperation, ModelAccessor modelAccessor, UICallBack uiCallback,
             Session session, IInterpreter interpreter, CommandContext context) {
        if (modelOperation instanceof DialogModelOperation) {
            DialogModelOperation dialogModelOperation = (DialogModelOperation) modelOperation;
            return Optional.of(new DialogTask(context, modelAccessor, interpreter, session, dialogModelOperation));
        }
        return Optional.empty();
    }

}

In this example, we will only consider the DialogModelOperation and we will return a new DialogTask used to open a dialog.