Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Orion/Documentation/Developer Guide/Plugging into the navigator"

m (todo)
(orion.navigate.openWith: Update for 0.4M1)
Line 58: Line 58:
  
 
= orion.navigate.openWith =
 
= orion.navigate.openWith =
** TODO update this section for 0.4M1 **
 
  
The <tt>orion.navigate.openWith</tt> service is used to contribute the location of an editor for a particular file type. This service is purely declarative, with no implementation methods required.
+
The <tt>orion.navigate.openWith</tt> service is used to associate a registered editor (see [[#orion.edit.editor | orion.edit.editor]]) with a registered content type (see [[Orion/Documentation/Developer_Guide/Core_client_services#orion.file.contenttype | orion.file.contenttype]]). Once this association has been made, the editor will be presented as a choice in the "Open With" menu beside files of that content type.  
  
 
== Service methods ==
 
== Service methods ==
  
None
+
None. This service is purely declarative.
  
 
== Service attributes ==
 
== Service attributes ==
Line 70: Line 69:
 
Implementations of <tt>orion.navigate.openWith</tt> must define the following attributes:
 
Implementations of <tt>orion.navigate.openWith</tt> must define the following attributes:
  
;name
+
;editor
:The name of the editor that opens with this service
+
:<code>String</code> The ID of the editor we want to associate. This must match exactly the ID that was given in [[#orion.edit.editor | orion.edit.editor]].
;href
+
;contentType
:The location of the editor to be opened. The variable <tt>${Location}</tt> is substituted with the URL of the file being edited.
+
: <code>String[]</code> An array of one or more content type IDs that will be associated with the editor.
;validationProperties
+
:An object specifying what file types this service is applicable to. Currently the only supported attribute is <tt>Name</tt>, specifying a regular expression to match on the file name.
+
  
 
== Example ==
 
== Example ==
  
Here is a sample plug-in that associates the Orion editor with <code>.md</code> (Markdown) files:
+
Here is a sample plug-in that associates the Orion Editor with the <code>"text.markdown"</code> content type. This example assumes that the <code>"text.markdown"</code> type has been previously registered with the [[Orion/Documentation/Developer_Guide/Core_client_services#orion.file.contenttype | orion.file.contenttype]] service.
<pre>
+
var provider = new eclipse.PluginProvider();
+
var serviceImpl = {};
+
var serviceProperties = {
+
  name: "Orion web editor",
+
  href: "/edit/edit.html#${Location}",
+
  validationProperties: {Name: "*.md"}
+
};
+
provider.registerServiceProvider("orion.navigate.openWith", serviceImpl, serviceProperties);
+
provider.connect();
+
</pre>
+
  
When this plug-in is installed, the user will see <tt>Orion web editor</tt> as an available target in the <b>Open With</b> Navigator menu beside <code>.md</code> files:
+
  var provider = new eclipse.PluginProvider();
 +
  provider.registerServiceProvider("orion.navigate.openWith", {},
 +
    {  id: "orion.editor",
 +
      contentType: ["text.markdown"]
 +
    });
 +
  provider.connect();
 +
 
 +
When this plug-in is installed, the user will see the Orion Editor as an available target in the <b>Open With</b> Navigator menu beside files of the Markdown content type:
  
 
[[Image:Orion-file-openWith-example.png]]
 
[[Image:Orion-file-openWith-example.png]]

Revision as of 14:41, 9 December 2011

Overview of contributing services to the Navigator

The Navigator page provides a view for users to browse and manipulate files in their workspace. The Navigator defines some services to allow plug-ins to contribute commands to this view.

orion.navigate.command

The orion.navigate.command service is used to contribute commands to the drop-down menu next to each file and folder. When the service is executed, the currently selected item in the Navigator is passed to the service's run method. The command can perform some operation on the provided selection, and optionally return an URL that the user will navigate to when clicking the command.

Service methods

Implementations of orion.navigate.command must define the following function:

run(selection)
Takes the navigator selection as an argument, and returns a URL string.

Service attributes

Implementations of orion.navigate.command may define the following attributes:

image
The URL of an icon to associate with the command
name
The command text show to the user
id
The command id
forceSingleItem
A boolean attribute specifying whether the command supports only a single selected item or multiple items
href
A boolean attribute indicating whether the command returns a link. If this attribute is specified and true, the command will render as a hyperlink and the user will navigate to the URL provided by the run method's return value.
tooltip
Tooltip text shown to the user when they hover on the command

Example

Here is a sample plug-in that contributes a link to a Google search for the selected file's name:

 var provider = new eclipse.PluginProvider({postInstallUrl:"/plugin/list.html"});
 provider.registerServiceProvider("orion.navigate.command", {
   run : function(item) {
     return "http://www.google.com/#q=" + item.Name;
   }
 }, {
   image: "http://www.google.com/favicon.ico",
   name: "Google Search",
   id: "sample.commands.sample4",
   forceSingleItem: true,
   href: true,
   tooltip: "Link to google search for this file name"
 });
 provider.connect();

When this plug-in is installed, the user will see the google search command in the Navigator menu as follows:

Orion-file-command-example.png

For more examples of contributing Navigator commands see the sample commands plugin.

orion.navigate.openWith

The orion.navigate.openWith service is used to associate a registered editor (see orion.edit.editor) with a registered content type (see orion.file.contenttype). Once this association has been made, the editor will be presented as a choice in the "Open With" menu beside files of that content type.

Service methods

None. This service is purely declarative.

Service attributes

Implementations of orion.navigate.openWith must define the following attributes:

editor
String The ID of the editor we want to associate. This must match exactly the ID that was given in orion.edit.editor.
contentType
String[] An array of one or more content type IDs that will be associated with the editor.

Example

Here is a sample plug-in that associates the Orion Editor with the "text.markdown" content type. This example assumes that the "text.markdown" type has been previously registered with the orion.file.contenttype service.

 var provider = new eclipse.PluginProvider();
 provider.registerServiceProvider("orion.navigate.openWith", {},
   {  id: "orion.editor",
      contentType: ["text.markdown"]
   });
 provider.connect();

When this plug-in is installed, the user will see the Orion Editor as an available target in the Open With Navigator menu beside files of the Markdown content type:

Orion-file-openWith-example.png

Back to the top