Class orion.commandregistry.CommandRegistry
CommandRegistry can render commands appropriate for a particular scope and DOM element.
Defined in: </shared/eclipse/e4/orion/I201404012230/bundles/org.eclipse.orion.client.ui/web/orion/commandRegistry.js>.
Constructor Attributes | Constructor Name and Description |
---|---|
Constructs a new command registry with the given options.
|
Method Attributes | Method Name and Description |
---|---|
addCommand(command)
Add a command to the command registry.
|
|
addCommandGroup(scopeId, groupId, position, title, parentPath, emptyGroupMessage, imageClass, tooltip, selectionClass, or)
Registers a command group and specifies visual information about the group.
|
|
Close any active parameter collector.
|
|
collectParameters(commandInvocation)
Collect the parameters specified in the given command invocation.
|
|
Returns whether this registry has been configured to collect command parameters
|
|
confirm(node, message, yesString, noString, modal, onConfirm)
Open a parameter collector to confirm a command.
|
|
destroy(parent)
Destroy all DOM nodes and any other resources used by rendered commands.
|
|
findCommand(commandId)
|
|
generateSeparatorImage(parent)
Add a dom node appropriate for using a separator between different groups
of commands.
|
|
Return the default selection service that is being used when commands should apply against a selection.
|
|
openParameterCollector(node, fillFunction, onClose)
Open a parameter collector suitable for collecting information about a command.
|
|
processURL(url)
Process the provided URL to determine whether any commands should be invoked.
|
|
registerCommandContribution(scopeId, commandId, position, parentPath, bindingOnly, keyBinding, urlBinding)
Register a command contribution, which identifies how a command appears
on a page and how it is invoked.
|
|
registerSelectionService(scopeId, selectionService)
Register a selection service that should be used for certain command scopes.
|
|
renderCommands(scopeId, parent, items, handler, renderType, userData, domNodeWrapperList)
Render the commands that are appropriate for the given scope.
|
|
runCommand(commandId, item, handler, parameters)
Run the command with the specified commandId.
|
|
setParameterCollector(parameterCollector)
Provide an object that can collect parameters for a given "tool" command.
|
|
showKeyBindings(keyAssist)
Show the keybindings that are registered with the command registry inside the specified target node.
|
|
unregisterCommandContribution(scopeId, commandId, parentPath)
|
Class Detail
orion.commandregistry.CommandRegistry(options)
Constructs a new command registry with the given options.
- Parameters:
- {Object} options
- The registry options object
- {orion.selection.Selection} options.selection Optional
- Optional selection service.
Method Detail
addCommand(command)
Add a command to the command registry. Nothing will be shown in the UI
until this command is referenced in a contribution.
- Parameters:
- {orion.commands.Command} command
- The command being added.
- See:
- registerCommandContribution
addCommandGroup(scopeId, groupId, position, title, parentPath, emptyGroupMessage, imageClass, tooltip, selectionClass, or)
Registers a command group and specifies visual information about the group.
- Parameters:
- {String} scopeId
- The id of a DOM element in which the group should be visible. Required. When commands are rendered for a particular element, the group will be shown only if its scopeId matches the id being rendered.
- {String} groupId
- The id of the group, must be unique. May be used for a dom node id of the element representing the group
- {Number} position
- The relative position of the group within its parent. Required.
- {String} title Optional
- The title of the group, optional
- {String} parentPath Optional
- The path of parent groups, separated by '/'. For example, a path of "group1Id/group2Id" indicates that the group belongs as a child of group2Id, which is itself a child of group1Id. Optional.
- {String} emptyGroupMessage Optional
- A message to show if the group is empty and the user activates the UI element representing the group. Optional. If not specified, then the group UI element won't be shown when it is empty.
- {String} imageClass Optional
- CSS class of an image to use for this group.
- {String} tooltip Optional
- Tooltip to show on this group. If not provided, and the group uses an
imageClass
, thetitle
will be used as the tooltip. - {String} selectionClass Optional
- CSS class to be appended when the command button is selected. Optional.
- {String} or
- {boolean} [defaultActionId] Id of an action from this group that should be invoked when the group is selected. This will add an
arrow to the grup that will open the dropdown. Optionally this can be set to
true
instead of adding a particular action. If set totrue
the group will be renderer as if there was a default action, but instead of invoking the default action it will open the dropdown. Optional.
closeParameterCollector()
Close any active parameter collector. This method should be used to deactivate a
parameter collector that was opened with
openParameterCollector
.
Commands that describe their required parameters do not need to use this method
because the command framework will open and close parameter collectors as needed and
call the command callback with the values of those parameters.
collectParameters(commandInvocation)
Collect the parameters specified in the given command invocation. If parameters are
collected successfully, invoke the command's callback. This method is used by clients who want to
control the timing of parameter collection. For example, if a command must be executed before it can
be determined what parameters are known, the client can try the command in the callback and then call
this function if parameters are needed. In this case, clients typically configure the parameters description
options with "options.clientWillCollect" set to true.
- Parameters:
- {orion.commands.CommandInvocation} commandInvocation
- the current invocation of the command
{Boolean}
collectsParameters()
Returns whether this registry has been configured to collect command parameters
- Returns:
- {Boolean} whether or not this registry is configured to collect parameters.
confirm(node, message, yesString, noString, modal, onConfirm)
Open a parameter collector to confirm a command.
- Parameters:
- {DOMElement} node
- the dom node that is displaying the command
- {String} message
- the message to show when confirming the command
- {String} yesString
- the label to show on a yes/true choice
- {String} noString
- the label to show on a no/false choice
- {Boolean} modal
- indicates whether the confirmation prompt should be modal.
- {Function} onConfirm
- a function that will be called when the user confirms the command. The function will be called with boolean indicating whether the command was confirmed.
destroy(parent)
Destroy all DOM nodes and any other resources used by rendered commands.
This call does not remove the commands from the command registry. Clients typically call this
function to empty a command area when a client wants to render the commands again due to some
change in state.
- Parameters:
- {String|DOMElement} parent
- The id or DOM node that should be emptied.
{orion.commands.Command}
findCommand(commandId)
- Parameters:
- {String} commandId
- Returns:
- {orion.commands.Command}
generateSeparatorImage(parent)
Add a dom node appropriate for using a separator between different groups
of commands. This function is useful when a page is precisely arranging groups of commands
(in a table or contiguous spans) and needs to use the same separator that the command registry
would use when rendering different groups of commands.
- Parameters:
- {DOMElement} parent
getSelectionService()
Return the default selection service that is being used when commands should apply against a selection.
openParameterCollector(node, fillFunction, onClose)
Open a parameter collector suitable for collecting information about a command.
Once a collector is created, the specified function is used to fill it with
information needed by the command. This method is used for commands that cannot
rely on a simple parameter description to collect parameters. Commands that describe
their required parameters do not need to use this method because the command framework
will open and close parameter collectors as needed and call the command callback with
the values of those parameters.
- Parameters:
- {DOMElement} node
- the dom node that is displaying the command, or a node in the parameter collector area
- {Function} fillFunction
- a function that will fill the parameter area
- {Function} onClose
- a function that will be called when the user closes the collector
processURL(url)
Process the provided URL to determine whether any commands should be invoked. Note that we never
invoke a command callback by URL, only its parameter collector. If a parameter collector is not
specified, commands in the URL will be ignored.
- Parameters:
- {String} url
- a url that may contain URL bindings.
registerCommandContribution(scopeId, commandId, position, parentPath, bindingOnly, keyBinding, urlBinding)
Register a command contribution, which identifies how a command appears
on a page and how it is invoked.
- Parameters:
- {String} scopeId
- The id describing the scope of the command. Required. This scope id is used when rendering commands.
- {String} commandId
- the id of the command. Required.
- {Number} position
- the relative position of the command within its parent. Required.
- {String} parentPath Optional, Default: null
- the path of any parent groups, separated by '/'. For example, a path of "group1Id/group2Id/command" indicates that the command belongs as a child of group2Id, which is itself a child of group1Id. Optional.
- {boolean} bindingOnly Optional, Default: false
- if true, then the command is never rendered, but the key or URL binding is hooked.
- {orion.editor.KeyBinding} keyBinding Optional
- a keyBinding for the command. Optional.
- {orion.commands.URLBinding} urlBinding Optional
- a url binding for the command. Optional.
registerSelectionService(scopeId, selectionService)
Register a selection service that should be used for certain command scopes.
- Parameters:
- {String} scopeId
- The id describing the scope for which this selection service applies. Required. Only contributions made to this scope will use the selection service.
- {orion.selection.Selection} selectionService
- the selection service for the scope.
renderCommands(scopeId, parent, items, handler, renderType, userData, domNodeWrapperList)
Render the commands that are appropriate for the given scope.
- Parameters:
- {String} scopeId
- The id describing the scope for which we are rendering commands. Required. Only contributions made to this scope will be rendered.
- {DOMElement} parent
- The element in which commands should be rendered. If commands have been previously rendered into this element, it is up to the caller to empty any previously generated content.
- {Object} items Optional
- An item or array of items to which the command applies. Optional. If no items are specified and a selection service was specified at creation time, then the selection service will be used to determine which items are involved.
- {Object} handler
- The object that should perform the command
- {String} renderType
- The style in which the command should be rendered. "tool" will render a tool image in the dom. "button" will render a text button. "menu" will render menu items.
- {Object} userData Optional
- Optional user data that should be attached to generated command callbacks
- {Object[]} domNodeWrapperList Optional
- Optional an array used to record any DOM nodes that are rendered during this call. If an array is provided, then as commands are rendered, an object will be created to represent the command's node. The object will always have the property "domNode" which contains the node created for the command. If the command is rendered using other means (toolkit widget) then the optional property "widget" should contain the toolkit object that represents the specified dom node.
runCommand(commandId, item, handler, parameters)
Run the command with the specified commandId.
- Parameters:
- {String} commandId
- the id of the command to run.
- {Object} item
- the item on which the command should run.
- {Object} handler
- the handler for the command.
- {orion.commands.ParametersDescription} parameters
- used on this invocation. Optional. Note: The current implementation will only run the command if a URL binding has been specified, or if an item to run the command against has been specified.
setParameterCollector(parameterCollector)
Provide an object that can collect parameters for a given "tool" command. When a command that
describes its required parameters is shown in a toolbar (as an image, button, or link), clicking
the command will invoke any registered parameterCollector before calling the command's callback.
This hook allows a page to define a standard way for collecting required parameters that is
appropriate for the page architecture. If no parameterCollector is specified, then the command callback
will be responsible for collecting parameters.
- Parameters:
- {orion.commandregistry.ParameterCollector} parameterCollector
showKeyBindings(keyAssist)
Show the keybindings that are registered with the command registry inside the specified target node.
- Parameters:
- {KeyAssistPanel} keyAssist
- the key assist panel
unregisterCommandContribution(scopeId, commandId, parentPath)
- Parameters:
- scopeId
- commandId
- parentPath