Click or drag to resize
AlchemyCommand Sets

Command Sets are what actually registers an Anguilla JavaScript Command and ties that command name to a specific interface (that was given during the creation of the JavaScript command file). The command set is not a stand alone piece and must be added as a reference to the ResourceGroup that contains the files for the commands in this set.

This topic contains the following sections:

Creating Command Sets

Command Sets are added by creating a class within your plugin project that extends from Alchemy4Tridion.Plugins.GUI.ConfigurationCommandSet. Within the constructor of your class, you can add commands to the command set with the CommandSetAddCommand(String, String) method. Note that if you use the Alchemy.command wrapper to create your JavaScript commands, or if you use the same namespace conventsions (ie Alchemy.Plugins.YourPluginName.Commands.YourCommandName) that Alchemy would use, you can then register your commands with just the command names.

Registering commands with just the command name
public class MyCommandSet : CommandSet
{
    public MyCommandSet()
    {
        AddCommand("JustTheCommandName");
    }
}
Note Note

Alchemy uses conventions to allow for developers to shorthand things like commands. In the above example, the command is still being registered in the editor as <cfg:command name="JustTheCommandName" implementation="Alchemy.Plugins.MyPlugin.Commands.JustTheCommandName" /> .

If you are using a non-Alchemy namespace for your command implementations, you'll need to use the two arguments for the AddCommand method.

Registering commands with command name and implementation
public class MyCommandSet : CommandSet
{
    public MyCommandSet()
    {
        AddCommand("NotJustTheCommandName", "MyPlugins.Commandos.NotJustTheCommandName");
    }
}
Adding Your Command Set to a Resource Groups

As mentioned, creating command sets alone is not enough. You'll also have to add them as a reference within a Resource Group. You can do this in the Resource Group's constructor using the AddFileT method. You'll want to add it to the Resource Group that contains the actual files for the command set itself.

C#
public MyCommandsGroup()
{
    AddFile("MyCommandFile.js");
    AddFile<MyCommandSet>(); // we just added a reference to our command set.

    Dependencies.AddAlchemyCore();
}
Command Set Dependencies

It's possible to add dependencies to your Command Set so the dependent resource groups will automatically be included anywhere your Command Set is referenced. This is done via the Dependencies property, and works the same way as adding dependencies to your Resource Groups.

Note Note

It's more typical to add dependencies to the Resource Group that references the Command Set rather than the Command Set itself.

Command Set Namespace Convention

When creating Command Sets with the zero argument base constructor, the generated id for your set is Alchemy.Plugins.YOUR_PLUGIN_NAME.Commands.CLASS_TYPE, where YOUR_PLUGIN_NAME is the name of your plugin (identified in the a4t.xml file) and CLASS_TYPE is the name of the class that you created representing your command set.

See Also