Jump to: navigation, search

Extending Real-Time Shared Editing for Use with Other Editors

With ECF 2.0.0/Ganymede, ECF introduces Real-Time Shared Editing.

By default, ECF supports doing shared editing with the JDT Java source code editor, and/or the default texteditor.

It's quite possible, however, and even easy, to support using the ECF real-time shared editing and synchronization with other types of text editors...for supporting shared editing source code for other languages (e.g. php, C/C++, javascript, xml editors, others) as well as shared editing of other types of text documents (properties editors, manifest/meta-data editors, etc.).

Below is a short explanation of how ECF supports doing real-time shared editing for the Java source code editor and the default text editor, and a short example of how ECF real-time shared editing can be added to other text editors.

Also, see ECF bug #238029.

How ECF Shared Editing Appears on an Editor's Context Menu

First, the DocShare plugin supports the Java source code editor and the default text editor by associating a menu contribution with the editor's context id. The current context ids for the java source code editor and default text editor are:

Java Source Code Editor Context ID: #CompilationUnitEditorContext Default Text Editor Context ID: #TextEditorContext

In the plugin.xml of the ECF DocShare plugin is the following markup

<extension point="org.eclipse.ui.menus">
  <menuContribution locationURI="popup:#CompilationUnitEditorContext">
    <dynamic class="org.eclipse.ecf.internal.provisional.docshare.menu.DocShareRosterMenuContributionItem"
             id="org.eclipse.ecf.editorshare.dynamic1">
    </dynamic>
  </menuContribution>
</extension>

<extension point="org.eclipse.ui.menus">
  <menuContribution locationURI="popup:#TextEditorContext">
    <dynamic class="org.eclipse.ecf.internal.provisional.docshare.menu.DocShareRosterMenuContributionItem"
             id="org.eclipse.ecf.editorshare.dynamic2">
    </dynamic>
  </menuContribution>
</extension>

Here is the plugin.xml in the CVS repo

The markup above results in the appearance of the Share Editor with menu item on the context menus of the Java Source Editor and the Default Text Editor. Note that the menu item will also appear on all editors that use/reuse these context ids.

Here is the Eclipse Help for Context ids.

If your editor uses/reuses these two ids as it's context id, then the ECF "Share Editor with" menu should appear in the editor's context view at runtime (when connected to an account that supports the ECF datashare API), and as long as the editor implements the ITextEditor interface, the ECF shared editing should work properly. If the editor supports this interface, but does not work properly, it is likely due to some problem with the editor implementation. It must, for example, support the IDocumentListener interface among some other in the org.eclipse.ui.jface.text bundle.

Using ECF Shared Editing with Other Text Editors

Given the approach above, it's rather easy to add the ECF Real-Time Shared Editing to other text editors. To do so, all that's required is ECF 2.0 with DocShare installed. ECF 2.0 runs on either Eclipse 3.3 or Eclipse 3.4 (see here to download ECF 2.0.

Then given a text editor with context id com.foo.MyContextID in either a new plugin, or an existing plugin, one can place markup like the following:

<extension point="org.eclipse.ui.menus">
  <menuContribution locationURI="popup:com.foo.MyContextID">
    <dynamic class="org.eclipse.ecf.internal.provisional.docshare.menu.DocShareRosterMenuContributionItem"
             id="com.foo.MyContextID.dynamic1">
    </dynamic>
  </menuContribution>
</extension>

This new or existing plugin will have a dependency on the org.eclipse.ecf.internal.provisional.docshare.menu.DocShareRosterMenuContributionItem class, as well as the org.eclipse.ui.menus extension point exposed by the Eclipse Platform.

When the plugin running this is run, and the user clicks on the editor's context menu, the Share Editor with menu item should be on the context menu. And if the editor implements ITextEditor and IDocumentListener as described above, then the ECF real-time shared editing should work with that editor.

If it does not, for whatever reason, please file a bug at bugs.eclipse.org under Technology->ECF and write to ecf-dev at eclipse.org.