orion.shell.command | ||
---|---|---|
![]() |
![]() |
|
Plugging into the shell | orion.shell.type |
The orion.shell.command service is used to contribute commands to the Shell page. When the service is executed, an object containing the user-supplied argument values is passed to the service's callback method. The command then optionally returns a response (a return value) to be displayed in the Shell page.
Implementations of orion.shell.command may define the following method:
window.parent.postMessage(JSON.stringify({pageService: "orion.page.delegatedUI", source: theCommandName, result: theResultValue}), "*");
The only context where a contributed command would not define this service method is to assist with the contribution of sub-commands. For example, to contribute commands "tar create" and "tar extract", a parent command "tar" without a service method must first be contributed.
Implementations of orion.shell.command define the following attributes:
The Shell page currently uses GCLI as its underlying shell widget, and consequently has adopted its syntax for parameter specification. For details on this syntax begin reading at the "## Default argument values" header in the GCLI Writing Commands doc. The basic parameter object attributes are:
The following "login" command implementation delegates to accompanying file "authenticationPrompter.html":
callback: function(args, context) { var result = new orion.Deferred(); var url = window.location.href; url = url.substring(0, url.lastIndexOf('/')); //$NON-NLS-0$ setTimeout(function() { result.progress({uriTemplate: url + "/authenticationPrompter.html", width: "400px", height: "100px"}); }); return result; }
authenticationPrompter.html shows simple username/password fields in the frame that has been provided to it by the Shell page. When the page's Submit button is pressed it performs the authentication and posts the result value. The frame showing this page is subsequently removed by the Shell page.
<head> <script> function authenticate() { /* do authentication here, assume is fine, so post result back to Shell page */ var result = "Authenticated user: " + document.getElementById("username").value; window.parent.postMessage(JSON.stringify({pageService: "orion.page.delegatedUI", source: "login", result: result}), "*"); return true; } </script> </head> <body> User name:<input type="text" id="username"><br> Password:<input type="password" id="password"> <button type="button" onclick="authenticate();" value="Submit">Submit</button> </body>
![]() |
![]() |
![]() |
Plugging into the shell | orion.shell.type |