Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342457 - [client] can't use Deferred in plugins
Summary: [client] can't use Deferred in plugins
Status: RESOLVED INVALID
Alias: None
Product: Orion
Classification: ECD
Component: Client (show other bugs)
Version: 0.2   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Susan McCourt CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-11 11:48 EDT by Szymon Brandys CLA
Modified: 2012-02-08 00:39 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Szymon Brandys CLA 2011-04-11 11:48:06 EDT
gitPlugin.html plugs in actions to the action toolbar in the file navigator. So far it worked well, however there is no way to handle asynchronous calls. 
For instance:

The code below works fine:

provider.registerServiceProvider("fileCommands", {
				run: function(item) {
					return "/git-log.html#" + item.Git.CommitLocation;
				}
			}, {
				name: "Git Log",
				id: "eclipse.git.log",
				tooltip: "Go to Git Log",
				validationProperties: {"Git":"*"},
				href: true,
				forceSingleItem: true
			});
			
It adds Git Log action that opens "/git-log.html#[resource]". However if an asynchronous call is needed in #run, returning Deferred does not work.
Comment 1 Susan McCourt CLA 2011-04-11 19:22:11 EDT
This is working for me.
I added a sample deferred command to sampleCommandsPlugin.html.  It looks like this:

provider.registerServiceProvider("fileCommands", {
	run : function(item) {
		var clientDeferred = new dojo.Deferred();
		window.setTimeout(function () {
			clientDeferred.callback(item.Location);
		}, 5000);
		return clientDeferred;
	}
}, {
	image: "/images/gear.gif",
	name: "Open HTML in 5 seconds",
	id: "sample.commands.sample11",
	forceSingleItem: true,
	href: true,
	validationProperties: {"Name":"*.html"},
	tooltip: "Show how a deferred can be used to do asynchronous computation"
});

This command seems to work OK.  So the question is...what is different about yours?  Maybe there is truly an error happening somewhere in your command.
Comment 2 Szymon Brandys CLA 2011-04-12 05:56:27 EDT
I added your code to gitPlugin.html and I get 
Error: Load timeout for plug-in: http://localhost:8080/plugins/gitPlugin.html in the console. So even you code does not work in the gitPlugin.
Comment 3 Szymon Brandys CLA 2011-04-12 05:57:17 EDT
More details from the log:

Error: Load timeout for plugin: http://localhost:8080/plugins/gitPlugin.html
Error(undefined=""Load timeout for plugi...plugins/gitPlugin.html"") (line 0)
_responseHandler(undefined=""onSecurityAlert"", undefined=""OpenAjax.hub.SecurityAlert.LoadTimeout"")pluginregistry.js (line 83)
(undefined="[object Object]", undefined=""OpenAjax.hub.SecurityAlert.LoadTimeout"")pluginregistry.js (line 308)
_8d(undefined=""OpenAjax.hub.SecurityAlert.LoadTimeout"")
Comment 4 Szymon Brandys CLA 2011-04-12 06:39:36 EDT
The issue here wa "validationProperties: {Name," that I copied and did not notice the error. Finally my code works.