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.
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 to discuss further the capabilities described here.
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.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.docshare.menu.DocShareRosterMenuContributionItem" id="org.eclipse.ecf.editorshare.dynamic2"> </dynamic> </menuContribution> </extension>
Here is the plugin.xml in the CVS repository.
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.
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).
For example, in the PDT PHP source editor, the context ID is org.eclipse.php.core.phpsource.source.EditorContext. With this context ID, one can create markup like the following:
<extension point="org.eclipse.ui.menus"> <menuContribution locationURI="popup:org.eclipse.php.core.phpsource.source.EditorContext"> <dynamic class="org.eclipse.ecf.docshare.menu.DocShareRosterMenuContributionItem" id="com.foo.MyEditorContextID.dynamic1"> </dynamic> </menuContribution> </extension>
The new or existing plugin that has this markup will have a dependency on the org.eclipse.ecf.docshare.menu.DocShareRosterMenuContributionItem class (and therefore the org.eclipse.ecf.docshare plugin), as well as the org.eclipse.ui.menus extension point exposed by the org.eclipse.ui plugin. When the plugin running this is run, and the user clicks on the PHP source editor's context menu, the Share Editor with menu item will appear. And since the editor implements ITextEditor and IDocumentListener as described above, the ECF real-time shared editing will work to show and synchronize the editor state.
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.
NOTE: People that wish to define a new/other UI for access to starting/stopping real-time shared editing may do so as they wish, and use the new Sync API (org.eclipse.ecf.sync) and the DocShare src code as example.
Creating a New Plugin
To create a new plugin, so that the markup above can be added to the plugin.xml, do the following
- Choose File->New->Project...->Plug-in Project->Next
- Give new project/plugin name->Next->Next
- Unselect the "Create a plug-in using one of the templates" check box->Finish
- Add org.eclipse.ecf.docshare plugin to Dependencies
- Add the markup like the above to plugin.xml (substituting your editor's context id for org.eclipse.php.core.phpsource.source.EditorContext and a new id for com.foo.MyEditorContextID.dynamic1.
Then run/debug a new Eclipse Application, and include your new plugin. After connecting to an XMPP/XMPPS account, and opening the editor, you should see the Share Editor with item on the context menu.
|Eclipse Communication Framework|
|API Documentation • Javadoc • Providers • ECF/Bot Framework|
|Servers • Shared Editing • Shared Code Plug-in|
|Development Guidelines • Integrators Guide|