bundles/org.eclipse.orion.client.ui/web/orion/sites/siteCommands.js
function createSiteServiceCommands(serviceRegistry, commandService, options) {
		function getFileService(siteServiceRef) {
			return mSiteClient.getFileClient(serviceRegistry, siteServiceRef.getProperty('filePattern')); //$NON-NLS-0$
		}
		options = options || {};
		var createCommand = new mCommands.Command({
			name : messages["Create"],
			tooltip: messages["Create a new site configuration"],
			id: "orion.site.create", //$NON-NLS-0$
			parameters: new mCommandRegistry.ParametersDescription([new mCommandRegistry.CommandParameter('name', 'text', messages["Name"])]), //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
			visibleWhen: function(bah) {
				return true;
			},
			callback : function(data) {
				var siteServiceRef = data.items, siteService = serviceRegistry.getService(siteServiceRef);
				var fileService = getFileService(siteServiceRef);
				var name = data.parameters && data.parameters.valueFor('name'); //$NON-NLS-0$
				var progress = serviceRegistry.getService("orion.page.progress");
				(progress ? progress.progress(fileService.loadWorkspaces(), "Loading workspaces") : fileService.loadWorkspaces()).then(function(workspaces) {
			        var workspaceId = workspaces && workspaces[0] && workspaces[0].Id;
			        if (workspaceId && name) {
				        siteService.createSiteConfiguration(name, workspaceId).then(function(site) {
							options.createCallback(mSiteUtils.generateEditSiteHref(site), site);
						}, options.errorCallback);
			        }
				});
			}});
		commandService.addCommand(createCommand);
	}
function createSiteServiceCommands(serviceRegistry, commandService, options) {
		function getFileService(siteServiceRef) {
			return mSiteClient.getFileClient(serviceRegistry, siteServiceRef.getProperty('filePattern')); //$NON-NLS-0$
		}
		options = options || {};
		var createCommand = new mCommands.Command({
			name : messages["Create"],
			tooltip: messages["Create a new site configuration"],
			id: "orion.site.create", //$NON-NLS-0$
			parameters: new mCommandRegistry.ParametersDescription([new mCommandRegistry.CommandParameter('name', 'text', messages["Name"])]), //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
			visibleWhen: function(bah) {
				return true;
			},
			callback : function(data) {
				var siteServiceRef = data.items, siteService = serviceRegistry.getService(siteServiceRef);
				var fileService = getFileService(siteServiceRef);
				var name = data.parameters && data.parameters.valueFor('name'); //$NON-NLS-0$
				var progress = serviceRegistry.getService("orion.page.progress");
				(progress ? progress.progress(fileService.loadWorkspaces(), "Loading workspaces") : fileService.loadWorkspaces()).then(function(workspaces) {
			        var workspaceId = workspaces && workspaces[0] && workspaces[0].Id;
			        if (workspaceId && name) {
				        siteService.createSiteConfiguration(name, workspaceId).then(function(site) {
							options.createCallback(mSiteUtils.generateEditSiteHref(site), site);
						}, options.errorCallback);
			        }
				});
			}});
		commandService.addCommand(createCommand);
	}
function createSiteServiceCommands ( serviceRegistry , commandService , options ) { function getFileService ( siteServiceRef ) { return mSiteClient . getFileClient ( serviceRegistry , siteServiceRef . getProperty ( 'filePattern' ) ) ; //$NON-NLS-0$ } options = options || { } ; var createCommand = new mCommands . Command ( { name : messages [ "Create" ] , tooltip : messages [ "Create a new site configuration" ] , id : "orion.site.create" , //$NON-NLS-0$ parameters : new mCommandRegistry . ParametersDescription ( [ new mCommandRegistry . CommandParameter ( 'name' , 'text' , messages [ "Name" ] ) ] ) , //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ visibleWhen : function ( bah ) { return true ; } , callback : function ( data ) { var siteServiceRef = data . items , siteService = serviceRegistry . getService ( siteServiceRef ) ; var fileService = getFileService ( siteServiceRef ) ; var name = data . parameters && data . parameters . valueFor ( 'name' ) ; //$NON-NLS-0$ var progress = serviceRegistry . getService ( "orion.page.progress" ) ; ( progress ? progress . progress ( fileService . loadWorkspaces ( ) , "Loading workspaces" ) : fileService . loadWorkspaces ( ) ) . then ( function ( workspaces ) { var workspaceId = workspaces && workspaces [ 0 ] && workspaces [ 0 ] . Id ; if ( workspaceId && name ) { siteService . createSiteConfiguration ( name , workspaceId ) . then ( function ( site ) { options . createCallback ( mSiteUtils . generateEditSiteHref ( site ) , site ) ; } , options . errorCallback ) ; } } ) ; } } ) ; commandService . addCommand ( createCommand ) ; }
Creates & adds commands that act on an site service.
@param {orion.serviceregistry.ServiceRegistry} serviceRegistry
@param {Function} options.createCallback
@param {Function} options.errorCallback
@name orion.sites.siteCommands#createSiteServiceCommands
Creates & adds commands that act on an site service .