In Methode Swing it is possible to configure context menus in the Explorer area

Prepare the plugin to add menus and action

In general, all the extensions of Méthode Swing are places under

{SWING-APP}/plugins

So, all the Javascript described in the following sections should be placed under

{SWING-APP}/app/plugins/{EXTENSION-FOLDER}/{EXTENSION-NAME}.js

Do not use the word libs as an extension folder. The libs folder is reserved for loading external libs. See the proper documentation to obtain further info on the topic.

DEBUG MODE: by default, all plugins are aggregated into a single plugins.js file at the Tomcat startup. When creating a plugin, it may be frustrating to restart the Tomcat Server every time a change is made.

To avoid this, set the configuration property debugEnabled to true.

Then, that extension will be loaded on every refresh of the page.

Add a context menu

In order to add a custom context menu to Methode Swing, it is necessary to use the following namespace:

eidosmedia.webclient.extensions.contextMenu

The syntax is the following:

eidosmedia.webclient.extensions.contextMenu.add(name, options);

Where:

  • name [string] is the name of the custom menu, alias a unique identifier.

  • options [optional, object] is a Javascript object containing the properties of the custom actions.

The options parameter can be omitted. In this case, Swing will use the previously registered command with the same name property. See example below.

If options is specified, it must follow the guidelines of a generic Swing command. See Commands documentation for further information.

Example

eidosmedia.webclient.commands.add({
    name: 'complex',
    label: 'Perform some complex operation...',
    isActive: function(ctx) {
        return ctx.activeObject.getType() === 'Image';
    },
    action: function( ctx, params, callback ) {
        alert('Performing action on ' + ctx.activeObject.getName());
    }
});

eidosmedia.webclient.extensions.contextMenu.add('complex');