Remove lane actions


#1

Hi,
I want to remove the following Lane actions:

  1. Divide into two Lanes
  2. Divide into three Lanes

Would you please help me?

best regards,
mehdy


#2

The ContextPadProvider is the right place to make changes.


#3

Hi philippfromme,

Thanks. I have implemented CustomContextPadProvider, but actually we have both of them at run-time. I mean ConextPadProvider and CustomContextPadProvider. It seems we have to remove the default context provider. I mean ContextPad.getEntries loops all providers and fill entries array and because of we have both ContextPadProvider and CustomContextPadProvider, my changes do not applied.

export class CustomContextPadProvider extends BpmnContextPadProvider {

static $inject = ['config.contextPad', 'injector', 'eventBus', 'contextPad', 'modeling', 'elementFactory', 'connect', 'create', 'popupMenu', 'canvas', 'rules', 'translate'];
constructor(config: any, injector: any, eventBus: any, contextPad: any, modeling: any, elementFactory: any, connect: any, create: any, popupMenu: any, canvas: any, rules: any, translate: any) {
    super(config, injector, eventBus, contextPad, modeling, elementFactory, connect, create, popupMenu, canvas, rules, translate);
}

getContextPadEntries(element: BPMN.DiElement) {
    var result = super.getContextPadEntries(element);

    if (element.type == "bpmn:Lane") {
        delete result["lane-divide-two"];
        delete result["lane-divide-three"];
    }

    return result;
}

}

Would you please help me?


#4

This won’t work. var result = super.getContextPadEntries(element); will return the context pad entries from the default provider, yes, but deleting from this won’t affect the entries that have already been retrieved by ContextPad. You need to override the default provider as shown in the custom elements example.


#5

Hi,
I think my way is ok because I did similar for ReplaceMenuProvider and BpmnRenderer and they are working fine. but for ContextPadProvider I think I have problem with a getEntries method in dist/bpmn-modelrer.development.js

ContextPad.prototype.getEntries = function(element) {
var entries = {};

// loop through all providers and their entries.
// group entries by id so that overriding an entry is possible
forEach(this._providers, function(provider) {
var e = provider.getContextPadEntries(element);

forEach(e, function(entry, id) {
  entries[id] = entry;
});

});

return entries;
};

I mean the this._providers returns ContextPadProvider and CustomContextPadProvider. So my code removes the actions for the Lane elements but actually changes revert by getEntries method. The question is why we have both default and override providers.

NOTE: my coding style is differ and it is because I am in Visual Studio and TypeScript.


#6

If you want to override the default provider have a look at the custom elements example again. This is exactly what’s happening there.


#7

Thanks,
I found the problem and it has already fixed.
We should have the new provider with the same name of default provider. (contextPadProvider)

///
import * as Modeler from “bpmn-js/lib/Modeler”
import * as BpmnContextPadProvider from “bpmn-js/lib/features/context-pad/ContextPadProvider”
import * as BpmnUtils from ‘./BpmnUtils’
import { Lite, liteKey } from ‘…/…/…/…/Framework/Signum.React/Scripts/Signum.Entities’

export class CustomContextPadProvider extends BpmnContextPadProvider {

static $inject = ['config.contextPad', 'injector', 'eventBus', 'contextPad', 'modeling', 'elementFactory', 'connect', 'create', 'popupMenu', 'canvas', 'rules', 'translate'];
constructor(config: any, injector: any, eventBus: any, contextPad: any, modeling: any, elementFactory: any, connect: any, create: any, popupMenu: any, canvas: any, rules: any, translate: any) {
    super(config, injector, eventBus, contextPad, modeling, elementFactory, connect, create, popupMenu, canvas, rules, translate);
}

getContextPadEntries(element: BPMN.DiElement) {
    var result = super.getContextPadEntries(element);

    delete result["append.text-annotation"];

    if (element.type == "bpmn:Lane" || element.type == "bpmn:Participant") {
        delete result["lane-divide-two"];
        delete result["lane-divide-three"];

        if (element.type == "bpmn:Participant") {
            delete result["connect"];
        }
    }

    return result;
}

}

export var init = [‘contextPadProvider’]; <====
export var contextPadProvider = [‘type’, CustomContextPadProvider]; <====


#8

Yes, using the same name is the way to override it. Sorry, if I wasn’t clear about that.


#9

Perfect,

best regards
mehdy