bundles/org.eclipse.orion.client.ui/web/orion/globalCommands.js
function setInvocation(commandItem) {
			var command = commandItem.command;
			if (!command.visibleWhen || command.visibleWhen(item)) {
				commandItem.invocation = new mCommands.CommandInvocation(item, item, null, command, commandRegistry);
				return new Deferred().resolve(commandItem);
			} else if (typeof alternateItem === "function") {
				if (!alternateItemDeferred) {
					alternateItemDeferred = alternateItem();
				}
				return Deferred.when(alternateItemDeferred, function (newItem) {
					if (newItem && (item === pageItem)) {
						// there is an alternate, and it still applies to the current page target
						if (!command.visibleWhen || command.visibleWhen(newItem)) {
							commandItem.invocation = new mCommands.CommandInvocation(newItem, newItem, null, command, commandRegistry);
							return commandItem;
						}
					}
				});
			}
			return new Deferred().resolve();
		}
function setInvocation(commandItem) {
			var command = commandItem.command;
			if (!command.visibleWhen || command.visibleWhen(item)) {
				commandItem.invocation = new mCommands.CommandInvocation(item, item, null, command, commandRegistry);
				return new Deferred().resolve(commandItem);
			} else if (typeof alternateItem === "function") {
				if (!alternateItemDeferred) {
					alternateItemDeferred = alternateItem();
				}
				return Deferred.when(alternateItemDeferred, function (newItem) {
					if (newItem && (item === pageItem)) {
						// there is an alternate, and it still applies to the current page target
						if (!command.visibleWhen || command.visibleWhen(newItem)) {
							commandItem.invocation = new mCommands.CommandInvocation(newItem, newItem, null, command, commandRegistry);
							return commandItem;
						}
					}
				});
			}
			return new Deferred().resolve();
		}
function setInvocation ( commandItem ) { var command = commandItem . command ; if ( ! command . visibleWhen || command . visibleWhen ( item ) ) { commandItem . invocation = new mCommands . CommandInvocation ( item , item , null , command , commandRegistry ) ; return new Deferred ( ) . resolve ( commandItem ) ; } else if ( typeof alternateItem === "function" ) { if ( ! alternateItemDeferred ) { alternateItemDeferred = alternateItem ( ) ; } return Deferred . when ( alternateItemDeferred , function ( newItem ) { if ( newItem && ( item === pageItem ) ) { // there is an alternate, and it still applies to the current page target if ( ! command . visibleWhen || command . visibleWhen ( newItem ) ) { commandItem . invocation = new mCommands . CommandInvocation ( newItem , newItem , null , command , commandRegistry ) ; return commandItem ; } } } ) ; } return new Deferred ( ) . resolve ( ) ; }
Creates a CommandInvocation for given commandItem.
@returns {orion.Promise} A promise resolving to: commandItem with its "invocation" field set, or undefined if we failed
Creates a CommandInvocation for given commandItem .